Trait UploadedFileTrait
Provides a set of methods to honor the Psr-7 Uploaded File Interface.
Traits provide extended method support to classes without requiring a direct, linear chain of inheritance. This allows functions to inherit subsets of related methods without declaring a parent class.
In Oroboros core, ALL methods are granted to classes via traits, and the classes themselves are just containers that correlate their methods to an interface they are expected to honor. This approach maximizes interoperability, by entirely removing class inheritance as a requirement for extension of any class in this system.
3rd parties using this package are not expected to follow this approach,
but ALL of our internal class and logic structure does.
- oroboros\core\traits\libraries\file\UploadedFileTrait uses oroboros\core\traits\libraries\file\FileTrait
Direct Known Users
Indirect Known Users
Package: oroboros\core\psr7
Category: traits
License: The MIT License (MIT)
Author: Brian Dayhoff mopsyd@me.com
Version: 0.2.4
Since: 0.2.4-alpha
Used by: oroboros\core\interfaces\api\psr\Psr7Api::UPLOADEDFILE_ABSTRACT_CLASS
Used by: oroboros\core\interfaces\api\psr\Psr7Api::SERVERREQUEST_ABSTRACT_CLASS
Link: bitbucket.org/oroborosframework/oroboros-core/wiki/development/api/traits.md
Satisfies: \oroboros\core\interfaces\contract\libraries\file\UploadedFileContract
Satisfies: \Psr\Http\Message\UploadedFileInterface
Located at core/traits/libraries/file/UploadedFileTrait.php
Methods summary
public static
|
#
getUploadedFileCollection( array $files )
Returns a collection of UploadedFile objects from the full set of files passed in $_FILES |
public
|
#
__construct( array $uploaded_file )
|
public
StreamInterface
|
|
public
|
|
public
integer|null
|
|
public
integer
|
|
public
string|null
|
|
public
string|null
|
|
protected
|
|
private
|
#
_moveUploadedFile( type $filePath )
Handles the safe move operation, regardless of whether it is an http or cli environment. |
private
|
|
private
|
|
private static
type
|
#
_parseUploadedFilesStatic( array $files )
Corrects known edge-cases in the $_FILES superglobal structure that can be corrected through rekeying the array. |
private static
boolean
|
#
_validateUploadedFileArray( array $files )
Returns a boolean determination as to whether a provided array can be directly used to create a valid UploadedFile instance. |
private static
boolean
|
#
_isMultileafUploadedFileArray( array $files )
Returns a boolean determination as to whether the provided array is a multi-leaf file array that needs additional consideration. |
private static
Psr\Http\Message\UploadedFileInterface
|
#
_createUploadedFileInstance( type $files )
Creates an instance of the called class implementing this trait. This class must also implement \Psr\Http\Message\UploadedFileInterface, and it must either use the provided constructor or have one that is compatible with the one provided by this trait. |
private static
string
|
#
_getUploadedFileMultileafPathString( array $subject, string $path = null )
Contencates the multidimensional array structure into a collection compatible dot separated notation string. This allows this class to easily fix miskeyed $_FILES keys for multipart uploads without a ton of redundant recursion. |
private static
array
|
#
_extractUploadedFileLeafKeys( array $subject )
Returns the numeric leaf keys of a multidimensional array, ignoring the rest of the nested keys. |
private static
boolean
|
#
_checkUploadedFileLeafKeysAlreadyHandled( array $subject )
Checks if nested leaf keys are already instances of \Psr\Http\Message\FileUploadInterface |
private static
boolean
|
#
_checkUploadedFileLeafKeys( mixed $subject )
Checks all valid cases for nesting of ambiguous multi-leaf file arrays. |
private static
array
|
#
_reorderUploadedFileMultileafArray( array $subject )
Corrects the issue of the leaf keys of a multi-leaf file array being numeric instead of the expected keys from $_FILES |
Methods used from oroboros\core\traits\libraries\file\FileTrait
_copyFileTo()
,
_deleteFile()
,
_fileExists()
,
_fileIsInitialized()
,
_fileIsTemp()
,
_fileReadable()
,
_fileWriteable()
,
_getFileAlias()
,
_getFileExtension()
,
_getFileFullyQualifiedName()
,
_getFileInfoLink()
,
_getFileMimeType()
,
_getFileName()
,
_getFilePath()
,
_getFileSize()
,
_getFileStreamResource()
,
_initializeFileObject()
,
_loadFileCodex()
,
_moveFileTo()
,
_setFileContents()
,
_setFileEncodingValue()
,
_setFileExistsValue()
,
_setFileExtensionValue()
,
_setFileNameValue()
,
_setFilePathValue()
,
_setFileReadableValue()
,
_setFileSizeValue()
,
_setFileTempAliasValue()
,
_setFileType()
,
_setFileTypeValue()
,
_setFileWriteableValue()
,
_touchFile()
,
_truncateFile()
Properties summary
private
array
|
$_uploaded_file_valid_errors
Represents the subset of valid upload errors, as defined by PHP |
#
array(
UPLOAD_ERR_OK,
UPLOAD_ERR_INI_SIZE,
UPLOAD_ERR_FORM_SIZE,
UPLOAD_ERR_PARTIAL,
UPLOAD_ERR_NO_FILE,
UPLOAD_ERR_NO_TMP_DIR,
UPLOAD_ERR_CANT_WRITE,
UPLOAD_ERR_EXTENSION
)
|
private
integer
|
$_uploaded_file_error
Represents the upload error, if an error occurs. If this has a value of 0, then no upload error occurred. |
#
UPLOAD_ERR_OK
|
private
integer
|
$_uploaded_file_size
Represents the uploaded file size. |
#
0
|
private
boolean
|
$_uploaded_file_is_sapi
Represents whether or not the current PHP execution is sapi or non-sapi |
#
false
|
private
string
|
$_uploaded_file_default_stream_wrapper
Represents the default stream wrapper class. |
#
'\\oroboros\\core\\libraries\\stream\\Stream'
|
private
string
|
$_uploaded_file_stream_wrapper
Represents the current stream wrapper class, which is the default, unless substituted. |
#
'\\oroboros\\core\\libraries\\stream\\Stream'
|
Properties used from oroboros\core\traits\libraries\file\FileTrait
$_file_encoding
,
$_file_exists
,
$_file_extension
,
$_file_extension_information
,
$_file_is_initialized
,
$_file_is_temp
,
$_file_mime
,
$_file_name
,
$_file_path
,
$_file_readable
,
$_file_size
,
$_file_temp_alias
,
$_file_type_info
,
$_file_writeable