PHP Interface PhpSpec\ServiceContainer

Mostrar archivo Open project: phpspec/phpspec Interface Usage Examples

Public Methods

Method Description
define ( string $id, callable $definition, array $tags = [] ) Sets a factory for the service creation. The same service will be returned every time
get ( string $id ) : object Retrieves a service from the container
getByTag ( string $tag ) : array Finds all services tagged with a particular string
getParam ( string $id, mixed $default = null ) : mixed Gets a param from the container or a default value.
has ( $id ) : boolean Determines whether a service is defined
remove ( string $id ) Removes a service from the container
set ( string $id, object $service, array $tags = [] ) Sets a object to be used as a service
setParam ( string $id, mixed $value ) Sets a param in the container

Method Details

define() public method

Sets a factory for the service creation. The same service will be returned every time
public define ( string $id, callable $definition, array $tags = [] )
$id string
$definition callable
$tags array

get() public method

Retrieves a service from the container
public get ( string $id ) : object
$id string
return object

getByTag() public method

Finds all services tagged with a particular string
public getByTag ( string $tag ) : array
$tag string
return array

getParam() public method

Gets a param from the container or a default value.
public getParam ( string $id, mixed $default = null ) : mixed
$id string
$default mixed
return mixed

has() public method

Determines whether a service is defined
public has ( $id ) : boolean
$id
return boolean

remove() public method

Removes a service from the container
public remove ( string $id )
$id string

set() public method

Sets a object to be used as a service
public set ( string $id, object $service, array $tags = [] )
$id string
$service object
$tags array

setParam() public method

Sets a param in the container
public setParam ( string $id, mixed $value )
$id string
$value mixed