PHP Class Robbo\Presenter\Presenter

Inheritance: implements ArrayAccess
Show file Open project: robclancy/presenter Class Usage Examples

Protected Properties

Property Type Description
$__decorator Decorator The decorator instance so we can nest presenters. Underscores here to avoid conflicts if a presenter or object has "decorator" as a variable.
$object mixed The object injected on Presenter construction.

Public Methods

Method Description
__call ( string $method, array $arguments ) : mixed Pass any uknown methods through to the inject object.
__construct ( mixed $object ) Create the Presenter and store the object we are presenting.
__get ( string $var ) : mixed Pass any unknown variable calls to present{$variable} or fall through to the injected object.
__isset ( string $name ) : boolean Allow ability to run isset() on a variable
__unset ( string $name ) Allow to unset a variable through the presenter
getObject ( ) : mixed Get the object we are wrapping.
offsetExists ( $offset ) * This will be called when isset() is called via array access.
offsetGet ( mixed $offset ) : mixed Add ability to access properties like an array.
offsetSet ( mixed $offset, mixed $value ) : void Set variable or key value using array access.
offsetUnset ( mixed $offset ) : void Unset a variable or key value using array access.
setExtendedDecorator ( Decorator $decorator ) : void This is so you can extend the decorator and inject it into the presenter at the class level so the new decorator will be used for nested presenters. Method name should be "setDecorator" however like above I want to make conflicts less likely.

Protected Methods

Method Description
__getDecorator ( ) Get the decorator, if none exists then use the default. Underscores here to avoid conflicts if a presenter or object needs to use "getDecorator".
getPresenterMethodFromVariable ( string $variable ) : string | null Fetch the 'present' method name for the given variable.

Method Details

__call() public method

Pass any uknown methods through to the inject object.
public __call ( string $method, array $arguments ) : mixed
$method string
$arguments array
return mixed

__construct() public method

Create the Presenter and store the object we are presenting.
public __construct ( mixed $object )
$object mixed

__get() public method

Pass any unknown variable calls to present{$variable} or fall through to the injected object.
public __get ( string $var ) : mixed
$var string
return mixed

__getDecorator() protected method

Get the decorator, if none exists then use the default. Underscores here to avoid conflicts if a presenter or object needs to use "getDecorator".
protected __getDecorator ( )

__isset() public method

Allow ability to run isset() on a variable
public __isset ( string $name ) : boolean
$name string
return boolean

__unset() public method

Allow to unset a variable through the presenter
public __unset ( string $name )
$name string

getObject() public method

Get the object we are wrapping.
public getObject ( ) : mixed
return mixed

getPresenterMethodFromVariable() protected method

Fetch the 'present' method name for the given variable.
protected getPresenterMethodFromVariable ( string $variable ) : string | null
$variable string
return string | null

offsetExists() public method

* This will be called when isset() is called via array access.
public offsetExists ( $offset )
$offset

offsetGet() public method

Add ability to access properties like an array.
public offsetGet ( mixed $offset ) : mixed
$offset mixed
return mixed

offsetSet() public method

Set variable or key value using array access.
public offsetSet ( mixed $offset, mixed $value ) : void
$offset mixed
$value mixed
return void

offsetUnset() public method

Unset a variable or key value using array access.
public offsetUnset ( mixed $offset ) : void
$offset mixed
return void

setExtendedDecorator() public static method

This is so you can extend the decorator and inject it into the presenter at the class level so the new decorator will be used for nested presenters. Method name should be "setDecorator" however like above I want to make conflicts less likely.
public static setExtendedDecorator ( Decorator $decorator ) : void
$decorator Decorator
return void

Property Details

$__decorator protected static property

The decorator instance so we can nest presenters. Underscores here to avoid conflicts if a presenter or object has "decorator" as a variable.
protected static Decorator,Robbo\Presenter $__decorator
return Decorator

$object protected property

The object injected on Presenter construction.
protected mixed $object
return mixed