CoreFiles by mySites.guru
create_uploaded_file.php40 lines, 1,192 bytes, from Joomla_4.2.4-Stable-Full_Package.zip
Raw History Compare with 4.2.3
md5
56e7394de3de177c0ca791b0b616524b
sha1
0a90862b3522839cbe4d3fedb86888e422444d58
sha256
14131985c0a011fe0ccd03412e04e02071e48d249435a44ca8e76f083083986f
<?php

/**
 * @see       https://github.com/laminas/laminas-diactoros for the canonical source repository
 * @copyright https://github.com/laminas/laminas-diactoros/blob/master/COPYRIGHT.md
 * @license   https://github.com/laminas/laminas-diactoros/blob/master/LICENSE.md New BSD License
 */

declare(strict_types=1);

namespace Laminas\Diactoros;

/**
 * Create an uploaded file instance from an array of values.
 *
 * @param array $spec A single $_FILES entry.
 * @throws Exception\InvalidArgumentException if one or more of the tmp_name,
 *     size, or error keys are missing from $spec.
 */
function createUploadedFile(array $spec) : UploadedFile
{
    if (! isset($spec['tmp_name'])
        || ! isset($spec['size'])
        || ! isset($spec['error'])
    ) {
        throw new Exception\InvalidArgumentException(sprintf(
            '$spec provided to %s MUST contain each of the keys "tmp_name",'
            . ' "size", and "error"; one or more were missing',
            __FUNCTION__
        ));
    }

    return new UploadedFile(
        $spec['tmp_name'],
        (int) $spec['size'],
        $spec['error'],
        $spec['name'] ?? null,
        $spec['type'] ?? null
    );
}

The same content is in 128 releases, Joomla 4.0.0-beta4 to 4.4.14. See them all, or every version of this file.