abstract class Singleton

An abstraction to apply to singleton instances for uniform initialization.

Properties

static protected Singleton[] $_instances

Methods

__construct()

Require a protected constructor so existing instances can be checked against.

static Singleton
instance(mixed $args = null)

Maybe initialize singleton instance and return the instance.

static array
get_instances()

Return a copy of the instances array.

get_class_reflection()

A short one-liner tool to get a ReflectionClass so we can get runtime info for the static class instance and not this abstract.

Details

at line 33
abstract protected __construct()

Require a protected constructor so existing instances can be checked against.

at line 42
final static Singleton instance(mixed $args = null)

Maybe initialize singleton instance and return the instance.

Parameters

mixed $args

The arguments to pass to the singleton constructor if constructing.

Return Value

Singleton

This instance.

at line 63
final static array get_instances()

Return a copy of the instances array.

Return Value

array

A list of Singleton instances that have been instantiated.

at line 72
final protected ReflectionClass get_class_reflection()

A short one-liner tool to get a ReflectionClass so we can get runtime info for the static class instance and not this abstract.

Return Value

ReflectionClass

The runtime instance of this class being evalutated.