MediaWiki REL1_34
Wikimedia\ParamValidator\Util\UploadedFile Class Reference

A simple implementation of UploadedFileInterface. More...

Inheritance diagram for Wikimedia\ParamValidator\Util\UploadedFile:
Collaboration diagram for Wikimedia\ParamValidator\Util\UploadedFile:

Public Member Functions

 __construct (array $data, $fromUpload=true)
 
 getClientFilename ()
 
 getClientMediaType ()
 
 getError ()
 
 getSize ()
 
 getStream ()
 
 moveTo ( $targetPath)
 

Private Member Functions

 checkError ()
 Throw if there was an error.
 

Private Attributes

array $data
 File data.
 
bool $fromUpload
 
bool $moved = false
 Whether moveTo() was called.
 
UploadedFileStream null $stream = null
 

Detailed Description

A simple implementation of UploadedFileInterface.

This exists so ParamValidator needn't depend on any specific PSR-7 implementation for a class implementing UploadedFileInterface. It shouldn't be used directly by other code, other than perhaps when implementing Callbacks::getUploadedFile() when another PSR-7 library is not already in use.

Since
1.34 @unstable

Definition at line 20 of file UploadedFile.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\ParamValidator\Util\UploadedFile::__construct ( array  $data,
  $fromUpload = true 
)
Parameters
array$dataData from $_FILES
bool$fromUploadSet false if using this task with data not from $_FILES. Intended for unit testing.

Definition at line 39 of file UploadedFile.php.

References Wikimedia\ParamValidator\Util\UploadedFile\$data, and Wikimedia\ParamValidator\Util\UploadedFile\$fromUpload.

Member Function Documentation

◆ checkError()

Wikimedia\ParamValidator\Util\UploadedFile::checkError ( )
private

Throw if there was an error.

Exceptions
RuntimeException

Definition at line 48 of file UploadedFile.php.

Referenced by Wikimedia\ParamValidator\Util\UploadedFile\getStream(), and Wikimedia\ParamValidator\Util\UploadedFile\moveTo().

◆ getClientFilename()

Wikimedia\ParamValidator\Util\UploadedFile::getClientFilename ( )

Definition at line 132 of file UploadedFile.php.

◆ getClientMediaType()

Wikimedia\ParamValidator\Util\UploadedFile::getClientMediaType ( )

Definition at line 137 of file UploadedFile.php.

◆ getError()

Wikimedia\ParamValidator\Util\UploadedFile::getError ( )

Definition at line 128 of file UploadedFile.php.

◆ getSize()

Wikimedia\ParamValidator\Util\UploadedFile::getSize ( )

Definition at line 124 of file UploadedFile.php.

◆ getStream()

Wikimedia\ParamValidator\Util\UploadedFile::getStream ( )

◆ moveTo()

Wikimedia\ParamValidator\Util\UploadedFile::moveTo (   $targetPath)

Member Data Documentation

◆ $data

array Wikimedia\ParamValidator\Util\UploadedFile::$data
private

File data.

Definition at line 23 of file UploadedFile.php.

Referenced by Wikimedia\ParamValidator\Util\UploadedFile\__construct().

◆ $fromUpload

bool Wikimedia\ParamValidator\Util\UploadedFile::$fromUpload
private

◆ $moved

bool Wikimedia\ParamValidator\Util\UploadedFile::$moved = false
private

Whether moveTo() was called.

Definition at line 32 of file UploadedFile.php.

◆ $stream

UploadedFileStream null Wikimedia\ParamValidator\Util\UploadedFile::$stream = null
private

The documentation for this class was generated from the following file: