Locator
in package
implements
ArrayAccess, Countable, IteratorAggregate
Service locator class
Tags
Interfaces, Classes, Traits and Enums
- ArrayAccess
- Countable
- IteratorAggregate
Table of Contents
- $loaded : array<string|int, mixed>
- Services that are loaded (instantiated)
- $services : array<string|int, mixed>
- Services
- $called : array<string|int, mixed>
- Recursion called service name tracker
- $depth : array<string|int, mixed>
- Recursion depth level tracker
- __construct() : mixed
- Constructor
- __get() : mixed
- Get a service
- __isset() : bool
- Determine if a service is available
- __set() : Locator
- Set a service
- __unset() : Locator
- Unset a service
- addParam() : Locator
- Add to a service's parameters
- count() : int
- Return count
- get() : mixed
- Get/load a service
- getCall() : mixed
- Get a service's callable string or object
- getIterator() : ArrayIterator
- Get iterator
- getParams() : mixed
- Get a service's parameters
- hasParams() : bool
- Check if a service has parameters
- isAvailable() : bool
- Determine of a service object is available (but not loaded)
- isLoaded() : bool
- Determine of a service object is loaded
- offsetExists() : bool
- Determine if a service is available
- offsetGet() : mixed
- Get a service
- offsetSet() : Locator
- Set a service
- offsetUnset() : Locator
- Unset a service
- remove() : Locator
- Remove a service
- removeParam() : Locator
- Remove a service's parameters
- set() : Locator
- Set a service. It will overwrite any previous service with the same name.
- setCall() : Locator
- Set a service's callable string or object
- setParams() : Locator
- Set a service's parameters
- setServices() : Locator
- Set service objects from an array of services
Properties
$loaded
Services that are loaded (instantiated)
protected
array<string|int, mixed>
$loaded
= []
$services
Services
protected
array<string|int, mixed>
$services
= []
$called
Recursion called service name tracker
private
static array<string|int, mixed>
$called
= []
$depth
Recursion depth level tracker
private
static array<string|int, mixed>
$depth
= 0
Methods
__construct()
Constructor
public
__construct([array<string|int, mixed> $services = null ][, bool $default = true ]) : mixed
Instantiate the service locator object.
Parameters
- $services : array<string|int, mixed> = null
- $default : bool = true
Tags
Return values
mixed —__get()
Get a service
public
__get(string $name) : mixed
Parameters
- $name : string
Tags
Return values
mixed —__isset()
Determine if a service is available
public
__isset(string $name) : bool
Parameters
- $name : string
Return values
bool —__set()
Set a service
public
__set(string $name, mixed $value) : Locator
Parameters
- $name : string
- $value : mixed
Tags
Return values
Locator —__unset()
Unset a service
public
__unset(string $name) : Locator
Parameters
- $name : string
Return values
Locator —addParam()
Add to a service's parameters
public
addParam(string $name, mixed $param[, mixed $key = null ]) : Locator
Parameters
- $name : string
- $param : mixed
- $key : mixed = null
Return values
Locator —count()
Return count
public
count() : int
Return values
int —get()
Get/load a service
public
get(string $name) : mixed
Parameters
- $name : string
Tags
Return values
mixed —getCall()
Get a service's callable string or object
public
getCall(string $name) : mixed
Parameters
- $name : string
Return values
mixed —getIterator()
Get iterator
public
getIterator() : ArrayIterator
Return values
ArrayIterator —getParams()
Get a service's parameters
public
getParams(string $name) : mixed
Parameters
- $name : string
Return values
mixed —hasParams()
Check if a service has parameters
public
hasParams(string $name) : bool
Parameters
- $name : string
Return values
bool —isAvailable()
Determine of a service object is available (but not loaded)
public
isAvailable(string $name) : bool
Parameters
- $name : string
Return values
bool —isLoaded()
Determine of a service object is loaded
public
isLoaded(string $name) : bool
Parameters
- $name : string
Return values
bool —offsetExists()
Determine if a service is available
public
offsetExists(string $offset) : bool
Parameters
- $offset : string
Return values
bool —offsetGet()
Get a service
public
offsetGet(string $offset) : mixed
Parameters
- $offset : string
Tags
Return values
mixed —offsetSet()
Set a service
public
offsetSet(string $offset, mixed $value) : Locator
Parameters
- $offset : string
- $value : mixed
Tags
Return values
Locator —offsetUnset()
Unset a service
public
offsetUnset(string $offset) : Locator
Parameters
- $offset : string
Return values
Locator —remove()
Remove a service
public
remove(string $name) : Locator
Parameters
- $name : string
Return values
Locator —removeParam()
Remove a service's parameters
public
removeParam(string $name, mixed $param[, mixed $key = null ]) : Locator
Parameters
- $name : string
- $param : mixed
- $key : mixed = null
Return values
Locator —set()
Set a service. It will overwrite any previous service with the same name.
public
set(string $name, mixed $service) : Locator
A service can be a CallableObject, callable string, or an array that contains a 'call' key and an optional 'params' key. Valid callable strings are:
'someFunction'
'SomeClass'
'SomeClass->foo'
'SomeClass::bar'
Parameters
- $name : string
- $service : mixed
Tags
Return values
Locator —setCall()
Set a service's callable string or object
public
setCall(string $name, mixed $call) : Locator
Parameters
- $name : string
- $call : mixed
Return values
Locator —setParams()
Set a service's parameters
public
setParams(string $name, mixed $params) : Locator
Parameters
- $name : string
- $params : mixed
Return values
Locator —setServices()
Set service objects from an array of services
public
setServices(array<string|int, mixed> $services) : Locator
Parameters
- $services : array<string|int, mixed>