PHP Class BulletProof\Image

Inheritance: implements ArrayAccess
Afficher le fichier Open project: samayo/bulletproof

Protected Properties

Свойство Type Description
$dimensions The max height and width image allowed
$fullPath The full image path (dir + image + mime)
$height The image height in pixels
$imageMimes list of known image types
$location The folder or image storage location
$mime The image mime type (extension)
$mimeTypes The mime types allowed for upload
$name The new image name, to be provided or will be generated.
$serialize A json format of all information about an image
$size The min and max image size allowed for upload (in bytes)
$width The image width in pixels

Méthodes publiques

Méthode Description
__construct ( array $_files = [] )
getError ( ) : string | boolean Returns error string or false if no errors occurred
getFullPath ( ) : string Returns the full path of the image ex "location/image.mime"
getHeight ( ) : integer Returns the image height in pixels
getJson ( ) : string Returns a JSON format of the image width, height, name, mime .
getLocation ( ) : string Returns the storage / folder name
getMime ( ) : string Returns the image mime type
getName ( ) : string Returns the image name
getSize ( ) : integer Returns the image size in bytes
getWidth ( ) : integer Returns the image width
moveUploadedFile ( $tmp_name, $destination ) : boolean Final upload method to be called, isolated for testing purposes
offsetExists ( $offset )
offsetGet ( mixed $offset ) : boolean | mixed Gets array value \ArrayAccess
offsetSet ( $offset, $value ) array offset \ArrayAccess unused
offsetUnset ( $offset )
setDimension ( $maxWidth, $maxHeight ) Sets acceptable max image height and width
setLocation ( $dir = "bulletproof", integer $permission = 438 ) Creates a location for upload storage
setMime ( array $fileTypes ) Define a mime type for uploading
setName ( $isNameProvided = null ) Renames image
setSize ( $min, $max ) Define a min and max image size for uploading
upload ( ) Main upload method.

Méthodes protégées

Méthode Description
getImageMime ( $tmp_name ) : boolean | string Gets the real image mime type
uploadErrors ( $e ) Checks for the common upload errors

Method Details

__construct() public méthode

public __construct ( array $_files = [] )
$_files array represents the $_FILES array passed as dependancy

getError() public méthode

Returns error string or false if no errors occurred
public getError ( ) : string | boolean
Résultat string | boolean

getFullPath() public méthode

Returns the full path of the image ex "location/image.mime"
public getFullPath ( ) : string
Résultat string

getHeight() public méthode

Returns the image height in pixels
public getHeight ( ) : integer
Résultat integer

getImageMime() protected méthode

Gets the real image mime type
protected getImageMime ( $tmp_name ) : boolean | string
$tmp_name string The upload tmp directory
Résultat boolean | string

getJson() public méthode

..
public getJson ( ) : string
Résultat string

getLocation() public méthode

Returns the storage / folder name
public getLocation ( ) : string
Résultat string

getMime() public méthode

Returns the image mime type
public getMime ( ) : string
Résultat string

getName() public méthode

Returns the image name
public getName ( ) : string
Résultat string

getSize() public méthode

Returns the image size in bytes
public getSize ( ) : integer
Résultat integer

getWidth() public méthode

Returns the image width
public getWidth ( ) : integer
Résultat integer

moveUploadedFile() public méthode

Final upload method to be called, isolated for testing purposes
public moveUploadedFile ( $tmp_name, $destination ) : boolean
$tmp_name int the temporary location of the image file
$destination int upload destination
Résultat boolean

offsetExists() public méthode

public offsetExists ( $offset )

offsetGet() public méthode

Gets array value \ArrayAccess
public offsetGet ( mixed $offset ) : boolean | mixed
$offset mixed
Résultat boolean | mixed

offsetSet() public méthode

array offset \ArrayAccess unused
public offsetSet ( $offset, $value )

offsetUnset() public méthode

public offsetUnset ( $offset )

setDimension() public méthode

Sets acceptable max image height and width
public setDimension ( $maxWidth, $maxHeight )
$maxWidth int max width value
$maxHeight int max height value

setLocation() public méthode

Creates a location for upload storage
public setLocation ( $dir = "bulletproof", integer $permission = 438 )
$dir string the folder name to create
$permission integer chmod permission

setMime() public méthode

Define a mime type for uploading
public setMime ( array $fileTypes )
$fileTypes array

setName() public méthode

Renames image
public setName ( $isNameProvided = null )

setSize() public méthode

Define a min and max image size for uploading
public setSize ( $min, $max )
$min int minimum value in bytes
$max int maximum value in bytes

upload() public méthode

This is where all the monkey business happens
public upload ( )

uploadErrors() protected méthode

Checks for the common upload errors
protected uploadErrors ( $e )
$e int error constant

Property Details

$dimensions protected_oe property

The max height and width image allowed
protected $dimensions

$fullPath protected_oe property

The full image path (dir + image + mime)
protected $fullPath

$height protected_oe property

The image height in pixels
protected $height

$imageMimes protected_oe property

list of known image types
protected $imageMimes

$location protected_oe property

The folder or image storage location
protected $location

$mime protected_oe property

The image mime type (extension)
protected $mime

$mimeTypes protected_oe property

The mime types allowed for upload
protected $mimeTypes

$name protected_oe property

The new image name, to be provided or will be generated.
protected $name

$serialize protected_oe property

A json format of all information about an image
protected $serialize

$size protected_oe property

The min and max image size allowed for upload (in bytes)
protected $size

$width protected_oe property

The image width in pixels
protected $width