PHP Class Papi_Container, papi

Inheritance: implements ArrayAccess
Show file Open project: wp-papi/papi

Protected Properties

Property Type Description
$classes array The classes holder.
$keys array The keys holder.
$values array The values holder.

Public Methods

Method Description
bind ( string $id, mixed $value = null, boolean $singleton = false ) : mixed Set a parameter or an object.
exists ( string $id ) : boolean Check if identifier is set or not.
is_singleton ( string $id ) : boolean Determine if a given type is a singleton or not.
make ( string $id, array $parameters = [] ) : Closure Resolve the given type from the container.
offsetExists ( string $id ) : boolean Check if identifier is set or not.
offsetGet ( string $id ) : mixed Get value by identifier.
offsetSet ( string $id, mixed $value ) Set a parameter or an object.
offsetUnset ( string $id ) Unset value by identifier.
once ( string $key, mixed $callback ) : mixed Add key and value to the container once.
remove ( string $id ) Unset value by identifier.
reset ( ) Reset container values.
singleton ( string $id, mixed $value = null ) : mixed Set a parameter or an object.

Protected Methods

Method Description
call_closure ( mixed $closure, array $parameters = [] ) : Closure Call closure.
get_class_prefix ( string $id, boolean $check = true ) : string Get class prefix.
get_closure ( mixed $value, boolean $singleton = false ) : Closure Get closure function.

Method Details

bind() public method

Set a parameter or an object.
public bind ( string $id, mixed $value = null, boolean $singleton = false ) : mixed
$id string
$value mixed
$singleton boolean
return mixed

call_closure() protected method

Call closure.
protected call_closure ( mixed $closure, array $parameters = [] ) : Closure
$closure mixed
$parameters array
return Closure

exists() public method

Check if identifier is set or not.
public exists ( string $id ) : boolean
$id string
return boolean

get_class_prefix() protected method

Get class prefix.
protected get_class_prefix ( string $id, boolean $check = true ) : string
$id string
$check boolean
return string

get_closure() protected method

Get closure function.
protected get_closure ( mixed $value, boolean $singleton = false ) : Closure
$value mixed
$singleton boolean
return Closure

is_singleton() public method

Determine if a given type is a singleton or not.
public is_singleton ( string $id ) : boolean
$id string
return boolean

make() public method

Resolve the given type from the container.
public make ( string $id, array $parameters = [] ) : Closure
$id string
$parameters array
return Closure

offsetExists() public method

Check if identifier is set or not.
public offsetExists ( string $id ) : boolean
$id string
return boolean

offsetGet() public method

Get value by identifier.
public offsetGet ( string $id ) : mixed
$id string
return mixed

offsetSet() public method

Set a parameter or an object.
public offsetSet ( string $id, mixed $value )
$id string
$value mixed

offsetUnset() public method

Unset value by identifier.
public offsetUnset ( string $id )
$id string

once() public method

Add key and value to the container once.
public once ( string $key, mixed $callback ) : mixed
$key string
$callback mixed
return mixed

remove() public method

Unset value by identifier.
public remove ( string $id )
$id string

reset() public method

Reset container values.
public reset ( )

singleton() public method

Set a parameter or an object.
public singleton ( string $id, mixed $value = null ) : mixed
$id string
$value mixed
return mixed

Property Details

$classes protected property

The classes holder.
protected array $classes
return array

$keys protected property

The keys holder.
protected array $keys
return array

$values protected property

The values holder.
protected array $values
return array