PHP Class ThumbBase, thinksns

This is the base class that all implementations must extend. It contains the core variables and functionality common to all implementations, as well as the functions that allow plugins to augment those classes.
Exibir arquivo Open project: medz/thinksns-4 Class Usage Examples

Protected Properties

Property Type Description
$errorMessage string The last error message raised
$fileName string This must include the path to the file (absolute paths recommended)
$format string What the file format is (mime-type)
$hasError boolean Whether or not the current instance has any errors
$imported array An array of imported plugin objects
$importedFunctions array An array of all methods added to this class by imported plugin objects
$isDataStream boolean By "raw file data" it's meant that we're actually passing the result of something like file_get_contents() or perhaps from a database blob
$remoteImage boolean Whether or not the image is hosted remotely

Public Methods

Method Description
__call ( string $method, array $args ) Calls plugin / imported functions
__construct ( $fileName, $isDataStream = false ) : ThumbBase Class constructor
getErrorMessage ( ) Returns $errorMessage.
getFileName ( ) Returns $fileName.
getFormat ( ) Returns $format.
getHasError ( ) Returns $hasError.
getImported ( ) : array Returns $imported.
getImportedFunctions ( ) : array Returns $importedFunctions.
importPlugins ( array $registry ) Imports plugins in $registry to the class
setErrorMessage ( object $errorMessage ) Sets $errorMessage.
setFileName ( object $fileName ) Sets $fileName.
setFormat ( object $format ) Sets $format.
setHasError ( object $hasError ) Sets $hasError.

Protected Methods

Method Description
fileExistsAndReadable ( ) Checks to see if $this->fileName exists and is readable
imports ( string $object ) Imports a plugin
triggerError ( string $errorMessage ) Sets $this->errorMessage to $errorMessage and throws an exception

Method Details

__call() public method

This is also where a fair amount of plugins magaic happens. This magic method is called whenever an "undefined" class method is called in code, and we use that to call an imported function. You should NEVER EVER EVER invoke this function manually. The universe will implode if you do... seriously ;)
public __call ( string $method, array $args )
$method string
$args array

__construct() public method

Class constructor
public __construct ( $fileName, $isDataStream = false ) : ThumbBase
return ThumbBase

fileExistsAndReadable() protected method

Checks to see if $this->fileName exists and is readable
protected fileExistsAndReadable ( )

getErrorMessage() public method

Returns $errorMessage.
See also: ThumbBase::$errorMessage
public getErrorMessage ( )

getFileName() public method

Returns $fileName.
See also: ThumbBase::$fileName
public getFileName ( )

getFormat() public method

Returns $format.
See also: ThumbBase::$format
public getFormat ( )

getHasError() public method

Returns $hasError.
See also: ThumbBase::$hasError
public getHasError ( )

getImported() public method

Returns $imported.
See also: ThumbBase::$imported
public getImported ( ) : array
return array

getImportedFunctions() public method

Returns $importedFunctions.
See also: ThumbBase::$importedFunctions
public getImportedFunctions ( ) : array
return array

importPlugins() public method

Imports plugins in $registry to the class
public importPlugins ( array $registry )
$registry array

imports() protected method

This is where all the plugins magic happens! This function "loads" the plugin functions, making them available as methods on the class.
protected imports ( string $object )
$object string The name of the object to import / "load"

setErrorMessage() public method

Sets $errorMessage.
See also: ThumbBase::$errorMessage
public setErrorMessage ( object $errorMessage )
$errorMessage object

setFileName() public method

Sets $fileName.
See also: ThumbBase::$fileName
public setFileName ( object $fileName )
$fileName object

setFormat() public method

Sets $format.
See also: ThumbBase::$format
public setFormat ( object $format )
$format object

setHasError() public method

Sets $hasError.
See also: ThumbBase::$hasError
public setHasError ( object $hasError )
$hasError object

triggerError() protected method

Also sets $this->hasError to true, so even if the exceptions are caught, we don't attempt to proceed with any other functions
protected triggerError ( string $errorMessage )
$errorMessage string

Property Details

$errorMessage protected_oe property

The last error message raised
protected string $errorMessage
return string

$fileName protected_oe property

This must include the path to the file (absolute paths recommended)
protected string $fileName
return string

$format protected_oe property

What the file format is (mime-type)
protected string $format
return string

$hasError protected_oe property

Whether or not the current instance has any errors
protected bool $hasError
return boolean

$imported protected_oe property

An array of imported plugin objects
protected array $imported
return array

$importedFunctions protected_oe property

An array of all methods added to this class by imported plugin objects
protected array $importedFunctions
return array

$isDataStream protected_oe property

By "raw file data" it's meant that we're actually passing the result of something like file_get_contents() or perhaps from a database blob
protected bool $isDataStream
return boolean

$remoteImage protected_oe property

Whether or not the image is hosted remotely
protected bool $remoteImage
return boolean