public static function prepareFiles(array $files)
    {
        $return = [];

        foreach ($files as $key => $value) {
            if ($value instanceof UploadedFileInterface) {
                $return[$key] = $value;

                continue;
            }

            // Nested files
            if (is_array($value) && isset($value['tmp_name'])) {
                $return[$key] = static::createUploadedFile($value);

                continue;
            }

            // get next level files
            if (is_array($value)) {
                $return[$key] = static::prepareFiles($value);

                continue;
            }

            throw new \InvalidArgumentException('Invalid value in files specification');
        }

        return $return;
    }
public static function prepareFiles(array $files)
    {
        $return = [];

        foreach ($files as $key => $value) {
            if ($value instanceof UploadedFileInterface) {
                $return[$key] = $value;

                continue;
            }

            // Nested files
            if (is_array($value) && isset($value['tmp_name'])) {
                $return[$key] = static::createUploadedFile($value);

                continue;
            }

            // get next level files
            if (is_array($value)) {
                $return[$key] = static::prepareFiles($value);

                continue;
            }

            throw new \InvalidArgumentException('Invalid value in files specification');
        }

        return $return;
    }
public static function prepareFiles ( array $ files ) { $ return = [ ] ; foreach ( $ files as $ key => $ value ) { if ( $ value instanceof UploadedFileInterface ) { $ return [ $ key ] = $ value ; continue ; } // Nested files if ( is_array ( $ value ) && isset ( $ value [ 'tmp_name' ] ) ) { $ return [ $ key ] = static :: createUploadedFile ( $ value ) ; continue ; } // get next level files if ( is_array ( $ value ) ) { $ return [ $ key ] = static :: prepareFiles ( $ value ) ; continue ; } throw new \ InvalidArgumentException ( 'Invalid value in files specification' ) ; } return $ return ; }
Normalize uploaded files

Transforms each value into an UploadedFileInterface instance, and ensures
that nested arrays are normalized.

@param   array $files THe $_FILES superglobal variable.

@return  UploadedFileInterface[]

@throws  \InvalidArgumentException for unrecognized values
Normalize uploaded files