Zend\Diactoros\UploadedFile::__construct PHP Method

__construct() public method

public __construct ( string | resource $streamOrFile, integer $size, integer $errorStatus, string | null $clientFilename = null, string | null $clientMediaType = null )
$streamOrFile string | resource
$size integer
$errorStatus integer
$clientFilename string | null
$clientMediaType string | null
    public function __construct($streamOrFile, $size, $errorStatus, $clientFilename = null, $clientMediaType = null)
    {
        if ($errorStatus === UPLOAD_ERR_OK) {
            if (is_string($streamOrFile)) {
                $this->file = $streamOrFile;
            }
            if (is_resource($streamOrFile)) {
                $this->stream = new Stream($streamOrFile);
            }
            if (!$this->file && !$this->stream) {
                if (!$streamOrFile instanceof StreamInterface) {
                    throw new InvalidArgumentException('Invalid stream or file provided for UploadedFile');
                }
                $this->stream = $streamOrFile;
            }
        }
        if (!is_int($size)) {
            throw new InvalidArgumentException('Invalid size provided for UploadedFile; must be an int');
        }
        $this->size = $size;
        if (!is_int($errorStatus) || 0 > $errorStatus || 8 < $errorStatus) {
            throw new InvalidArgumentException('Invalid error status for UploadedFile; must be an UPLOAD_ERR_* constant');
        }
        $this->error = $errorStatus;
        if (null !== $clientFilename && !is_string($clientFilename)) {
            throw new InvalidArgumentException('Invalid client filename provided for UploadedFile; must be null or a string');
        }
        $this->clientFilename = $clientFilename;
        if (null !== $clientMediaType && !is_string($clientMediaType)) {
            throw new InvalidArgumentException('Invalid client media type provided for UploadedFile; must be null or a string');
        }
        $this->clientMediaType = $clientMediaType;
    }