class Once

Constants

protected INSTANCE_CONTEXT_KEY

The context key for the current once instance.

protected ENABLED_CONTEXT_KEY

The context key for the once enabled flag.

Methods

__construct(WeakMap $values)

Create a new once instance.

static Once
instance()

Create a new once instance.

mixed
value(Onceable $onceable)

Get the value of the given onceable.

bool
usesSameObjects(array $references, array $objects)

Determine if the cached references still point to the given objects.

static void
enable()

Re-enable the once instance if it was disabled.

static void
disable()

Disable the once instance.

static void
flush()

Flush the once instance.

Details

at line 28
protected __construct(WeakMap $values)

Create a new once instance.

Parameters

WeakMap $values

at line 35
static Once instance()

Create a new once instance.

Return Value

Once

at line 43
mixed value(Onceable $onceable)

Get the value of the given onceable.

Parameters

Onceable $onceable

Return Value

mixed

at line 81
protected bool usesSameObjects(array $references, array $objects)

Determine if the cached references still point to the given objects.

Object hashes are based on object IDs, which PHP reuses once an object is destroyed.

Parameters

array $references
array $objects

Return Value

bool

at line 95
static void enable()

Re-enable the once instance if it was disabled.

Return Value

void

at line 103
static void disable()

Disable the once instance.

Return Value

void

at line 111
static void flush()

Flush the once instance.

Return Value

void