\Phabstractic\PatternsRegistry

The Registry Class

Encapsulates all the necessary functions to implement a registery. Truly, at the moment, implements a paired down \ArrayObject wrapper.

CHANGELOG

1.0: Documented Registry - May 4th, 2013 2.0: Reproduced Registry for Primus - April 2nd, 2015 3.0: Reformatted for inclusion in phabstractic - July 7th, 2016

Summary

Methods
Properties
Constants
hardened()
instantiate()
__construct()
set()
setReference()
get()
getReference()
offsetExists()
offsetGet()
offsetSet()
offsetUnset()
asort()
append()
count()
exchangeArray()
getArrayCopy()
getFlags()
getIterator()
getIteratorClass()
ksort()
natcasesort()
natsort()
uasort()
uksort()
No public properties found
No constants found
init()
$instance
$registry
N/A
__clone()
$flags
$iteratorClass
N/A

Properties

$instance

$instance : mixed

The single instance of the class

Type

mixed — The singular instance

$registry

$registry : array

Internal Registry Array

Type

array — The array under the hood

$flags

$flags : mixed

\ArrayObject Flags

Type

mixed — (??)

$iteratorClass

$iteratorClass : \ArrayIterator

The Iterator Class

(functionality undocumented here)

Type

\ArrayIterator

Methods

hardened()

hardened() : boolean

Test if the instance already exists

If it exists then it can't be instantiated with arguments

Returns

boolean —

True if instantiated

instantiate()

instantiate() : mixed

Gets The Singular Instance of the Singleton

This can be called with an array of 'options' (those really are supplied to the given instance). If there's an attempt to 'reconfigure' the singleton instance with new options a RuntimeException is thrown.

Throws

\Phabstractic\Patterns\Phabstractic\Patterns\Exception\RuntimeException

when instance is already defined and configured when given new configuration options

Returns

mixed —

The instance of the singleton class, the class itself

__construct()

__construct() 

For array compatibility

set()

set(string|integer  $index, mixed  $value) 

Set A Registry Value

Doesn't necessarily set a reference

Parameters

string|integer $index

The registry associated key

mixed $value

The registry value

setReference()

setReference(string|integer  $index,   $value) 

Explicitly Set A Registry Reference

For sure sets a reference in the registry

Parameters

string|integer $index

The registry associated key

$value

get()

get(string|integer  $index) : mixed

Retrieve Registry Value

May not return reference. This returns types\Null instead of null, this allows registry values to be the native null value and still make a distinction.

Parameters

string|integer $index

The index to retrieve

Returns

mixed —

The registry value, \Phabstractic\Data\Types\None otherwise

getReference()

getReference(string|integer  $index) : mixed

Explicitly Retrieve Value Refernce

This will for sure return a reference to the registry value at index This returns types\Null instead of null, this allows registry values to be the native null value and make a distinction.

Parameters

string|integer $index

The index to retrieve

Returns

mixed —

The registery value reference, \Phabstractic\Data\Types\None otherwise

offsetExists()

offsetExists(  $index) 

Parameters

$index

offsetGet()

offsetGet(  $index) 

Parameters

$index

offsetSet()

offsetSet(  $index,   $value) 

Parameters

$index
$value

offsetUnset()

offsetUnset(  $index) 

Parameters

$index

asort()

asort() 

append()

append(  $value) 

Parameters

$value

count()

count() 

exchangeArray()

exchangeArray(  $array) 

Parameters

$array

getArrayCopy()

getArrayCopy() 

getFlags()

getFlags() 

getIterator()

getIterator() 

getIteratorClass()

getIteratorClass() 

ksort()

ksort() 

natcasesort()

natcasesort() 

natsort()

natsort() 

uasort()

uasort(  $cmp_function) 

Parameters

$cmp_function

uksort()

uksort(  $cmp_function) 

Parameters

$cmp_function

init()

init(array  $data = array(), mixed  $flags = parent::ARRAY_AS_PROPS, string  $iteratorClass = '\\ArrayIterator') 

Registry Class Construction

This constructs the registry array with the given default values

Parameters

array $data

The array values to use

mixed $flags

The array 'flags' (such as \ArrayObject::ARRAY_AS_PROPS)

string $iteratorClass

The iterator class for the array, default \ArrayObject's default iterator

__clone()

__clone() 

You don't clone a singleton