ICanBoogie/HTTP v2.6.0
  • Namespace
  • Class

Namespaces

  • ICanBoogie
    • Exception
    • HTTP
      • Headers
      • Request
      • RequestDispatcher

Classes

  • CallableDispatcher
  • DispatcherProvider
  • File
  • FileInfo
  • FileList
  • FileResponse
  • Headers
  • ProvideDispatcher
  • RedirectResponse
  • Request
  • RequestDispatcher
  • RequestOptionsMapper
  • RequestRange
  • Response
  • Status
  • WeightedDispatcher

Interfaces

  • Dispatcher
  • Exception
  • FileOptions
  • RequestMethods
  • RequestOptions
  • ResponseStatus
  • SecurityError

Exceptions

  • AuthenticationRequired
  • ClientError
  • DispatcherNotDefined
  • DispatcherProviderNotDefined
  • ForceRedirect
  • MethodNotSupported
  • NotFound
  • PermissionRequired
  • ServerError
  • ServiceUnavailable
  • StatusCodeNotValid

Functions

  • dispatch
  • get_dispatcher
  • get_initial_request

Class File

Representation of a POST file.

ICanBoogie\HTTP\File implements ICanBoogie\ToArray, ICanBoogie\HTTP\FileOptions uses ICanBoogie\Accessor\AccessorTrait (not available)
Namespace: ICanBoogie\HTTP
Located at File.php

Methods summary

public static ICanBoogie\HTTP\File
# from( array|string $properties_or_name )

Creates a ICanBoogie\HTTP\File instance.

Creates a ICanBoogie\HTTP\File instance.

Parameters

$properties_or_name
An array of properties or a file identifier.

Returns

ICanBoogie\HTTP\File
protected string
# get_name( )

Returns the name of the file.

Returns the name of the file.

Returns

string
protected string
# get_unsuffixed_name( )

Returns the name of the file, without its extension.

Returns the name of the file, without its extension.

Returns

string
protected string|null
# get_type( )

Returns the type of the file.

Returns the type of the file.

If the ICanBoogie\HTTP\File::$type property was not defined during construct, the type is guessed from the name or the pathname of the file.

Returns

string|null
The MIME type of the file, or null if it cannot be determined.
protected integer|false
# get_size( )

Returns the size of the file.

Returns the size of the file.

If the ICanBoogie\HTTP\File::$size property was not defined during construct, the size is guessed using the pathname of the file. If the pathname is not available the method returns null.

Returns

integer|false
The size of the file or false if it cannot be determined.
protected boolean
# get_is_valid( )

Whether the file is valid.

Whether the file is valid.

A file is considered valid if it has no error code, if it has a size, if it has either a temporary name or a pathname and that the file actually exists.

Returns

boolean
true if the file is valid, false otherwise.
protected string
# get_pathname( )

Returns the pathname of the file.

Returns the pathname of the file.

Note: If the ICanBoogie\HTTP\File::$pathname property is empty, the ICanBoogie\HTTP\File::$tmp_name property is returned.

Returns

string
protected
# __construct( array $properties )
public array
# to_array( )

Returns an array representation of the instance.

Returns an array representation of the instance.

The following properties are exported:

  • ICanBoogie\HTTP\File::$name
  • $unsuffixed_name
  • $extension
  • ICanBoogie\HTTP\File::$type
  • ICanBoogie\HTTP\File::$size
  • ICanBoogie\HTTP\File::$pathname
  • ICanBoogie\HTTP\File::$error
  • $error_message

Returns

array
protected string
# get_error( )

Returns the error code.

Returns the error code.

Returns

string
protected ICanBoogie\I18n\FormattedString|ICanBoogie\FormattedString|string|null
# get_error_message( )

Returns the message associated with the error.

Returns the message associated with the error.

Returns

ICanBoogie\I18n\FormattedString|ICanBoogie\FormattedString|string|null
protected string|null
# get_extension( )

Returns the extension of the file, if any.

Returns the extension of the file, if any.

Note: The extension includes the dot e.g. ".zip". The extension is always in lower case.

Returns

string|null
protected boolean
# get_is_uploaded( )

Checks if a file is uploaded.

Checks if a file is uploaded.

Returns

boolean
true if the file is uploaded, false otherwise.
public boolean
# match( string|array $type )

Checks if the file matches a MIME class, a MIME type, or a file extension.

Checks if the file matches a MIME class, a MIME type, or a file extension.

Parameters

$type

The type can be a MIME class (e.g. "image"), a MIME type (e.g. "image/png"), or an extensions (e.g. ".zip"). An array can be used to check if a file matches multiple type e.g. [ "image", ".mp3" ], which matches any type of image or files with the ".mp3" extension.

Returns

boolean
true if the file matches (or $type is empty), false otherwise.
public
# move( string $destination, boolean $overwrite = self::MOVE_NO_OVERWRITE )

Moves the file.

Moves the file.

Parameters

$destination
Pathname to the destination file.
$overwrite

Use ICanBoogie\HTTP\File::MOVE_OVERWRITE to delete the destination before the file is moved. Defaults to ICanBoogie\HTTP\File::MOVE_NO_OVERWRITE.

Throws

Exception
if the file failed to be moved.

Constants summary

boolean MOVE_OVERWRITE
# true
boolean MOVE_NO_OVERWRITE
# false

Constants inherited from ICanBoogie\HTTP\FileOptions

OPTION_ERROR, OPTION_NAME, OPTION_PATHNAME, OPTION_SIZE, OPTION_TMP_NAME, OPTION_TYPE

Properties summary

protected string $name

Name of the file.

Name of the file.

#
protected $type
#
protected $size
#
protected $tmp_name
#
protected $error
#
protected $pathname
#

Magic properties

public read-only string $name

Name of the file.

public read-only string $type

MIME type of the file.

public read-only string $size

Size of the file.

public read-only string $error

Error code, one of UPLOAD_ERR_*.

public read-only string $error_message

A formatted message representing the error.

public read-only string $pathname

Pathname of the file.

public read-only string $extension

The extension of the file. If any, the dot is included e.g. ".zip".

public read-only string $unsuffixed_name

The name of the file without its extension.

public read-only boolean $is_uploaded

true if the file is uploaded, false otherwise.

public read-only boolean $is_valid

true if the file is valid, false otherwise. See: is_valid().

ICanBoogie/HTTP v2.6.0 API documentation generated by ApiGen