ServiceFactory
A factory for creating service instances that match the provider name and interface provided
Tags
Table of Contents
- $logger : Logger
- Trace logger.
- $singletons : array<string|int, mixed>
- A static array of service singletons in case any service needs to be accessed as a single instance.
- getInstance() : stdClass
- A static method that attempts to return a service provider instance based on the name of the provider class supplied. If the instance does not implement the desired interface, an exception is thrown.
Properties
$logger
Trace logger.
private
static Logger
$logger
= null
Tags
$singletons
A static array of service singletons in case any service needs to be accessed as a single instance.
private
static array<string|int, mixed>
$singletons
= array()
Tags
Methods
getInstance()
A static method that attempts to return a service provider instance based on the name of the provider class supplied. If the instance does not implement the desired interface, an exception is thrown.
public
static getInstance(string $serviceName, string $serviceInterface[, bool $isSingleton = false ]) : stdClass
Parameters
- $serviceName : string
-
The class name of the service class (fully qualified).
- $serviceInterface : string
-
The interface name of the service class returned (fully qualified).
- $isSingleton : bool = false
-
Set to true if the service instance requested is a singleton, default is false (you get a new instance each time).