Singleton
Allows just a single instance of the class using this trait.
Get the singleton by calling the static method getInstance()
.
If there is no object yet, the constructor is called with the same arguments
as getInstance()
. Any later call will just return the already instantiated
object (irrespective of the given arguments).
In order for this to work as expected, the constructor has to be implemented
as private
to prevent direct instantiation of the class.
Tags
Table of Contents
Methods
- __clone() : void
- This is a singleton class, thus cloning is prohibited.
- getInstance() : static
- Get a singleton instance of this class.
- __construct() : void
- This is a singleton class, thus the constructor is private.
Methods
__clone()
This is a singleton class, thus cloning is prohibited.
public
final __clone() : void
Tags
getInstance()
Get a singleton instance of this class.
public
final static getInstance(mixed ...$args) : static
APIYes
Parameters
- $args : mixed
-
Constructor arguments
Return values
static —The singleton instance
__construct()
This is a singleton class, thus the constructor is private.
private
abstract __construct() : void