PHP Class Ergo\Registry

Show file Open project: 99designs/ergo Class Usage Examples

Public Methods

Method Description
__get ( $key ) Magic property access
__isset ( $key ) Magic property access for isset
factory ( $key, $factory ) Registers a {@link Factory} or closure to be invoked on the first lookup
handle ( $key ) Creates a handle to a particular registry key
isRegistered ( $key ) Returns whether an object
lookup ( $key, $closure = null ) : Object Looks up a key in the registry, with an optional closure that that will be executed and the result stored if the key doesn't exist (and there is no trigger).
register ( $key, $object ) Registers an object for later retrieval by key. Any existing key is overwritten.
trigger ( $keys, $callable ) Sets a closure that is called on a lookup miss

Private Methods

Method Description
_memoize ( $object ) : Closure Returns a closure that returns an object.

Method Details

__get() public method

Magic property access
public __get ( $key )

__isset() public method

Magic property access for isset
public __isset ( $key )

factory() public method

Registers a {@link Factory} or closure to be invoked on the first lookup
public factory ( $key, $factory )

handle() public method

Creates a handle to a particular registry key
public handle ( $key )

isRegistered() public method

Returns whether an object
public isRegistered ( $key )

lookup() public method

Looks up a key in the registry, with an optional closure that that will be executed and the result stored if the key doesn't exist (and there is no trigger).
public lookup ( $key, $closure = null ) : Object
return Object

register() public method

Registers an object for later retrieval by key. Any existing key is overwritten.
public register ( $key, $object )

trigger() public method

Sets a closure that is called on a lookup miss
public trigger ( $keys, $callable )