Trait RegistryTrait
Provides a set of methods to abstract complex, scoped private values into a simple dot separated naming convention. Works with both arrays as well as objects, respecting visibility.
Array or object nesting is represented as a dot separated string notation, consistent with other languages namespacing such as javascript or MySQL. This allows for broader universalization of schema represenation without as much one-off parsing logic as PHP's internal schema normally allows without additional abstraction.
Public facing api's in this system honor standard notation. As such, this trait does not provide public methods, and you will have to expose them manually if used for interactive containerization.
- oroboros\core\traits\patterns\behavioral\RegistryTrait uses oroboros\core\traits\utilities\logic\BackreferenceTrait
Direct Known Users
oroboros\core\traits\libraries\container\ContainerTrait
,
oroboros\core\traits\patterns\creational\PrototyperTrait
Package: oroboros\core\patterns
Category: traits
License: The MIT License (MIT)
Author: Brian Dayhoff mopsyd@me.com
Version: 0.2.4-alpha
Since: 0.1.1
Link: bitbucket.org/oroborosframework/oroboros-core/wiki/development/api/contract_interface.md
Planned: This trait is set up to eventually also support tree search algorithms, though that is not yet implemented.
Planned:
The indexing functionality will eventually be separated from the container functionality into it's own trait, which will be used by this one. This should not change the protected or public api when this occurs.
Traits provide extended method support to classes without requiring a direct, linear chain of inheritance. This allows functions to inherit subsets of related methods without declaring a parent class.
In Oroboros core, ALL methods are granted to classes via traits, and the classes themselves are just containers that correlate their methods to an interface they are expected to honor. This approach maximizes interoperability, by entirely removing class inheritance as a requirement for extension of any class in this system.
3rd parties using this package are not expected to follow this approach,
but ALL of our internal class and logic structure does.
Located at core/traits/patterns/behavioral/RegistryTrait.php
Methods summary
protected
boolean
|
#
_getRegistryValue( scalar $key = null , boolean $safe,… )
|
protected
|
|
protected
array
|
|
protected
integer|boolean
|
#
_countRegistryKeys( scalar $key = null )
|
protected
boolean
&
|
#
_getRegistryValueReference( scalar $key = null , boolean $safe,… )
|
final protected
boolean
|
#
_checkRegistryValue( scalar $key )
|
final protected
boolean
|
#
_setRegistryValue( scalar $key, boolean $value = array(), $safe = false )
|
final protected
|
|
final protected
string
|
|
final protected
|
#
_resetRegistryIndexSeparator( )
Resets the recognized registry index separator to it's default ["."]. |
protected
|
#
_setRegistryIndexSeparator( string $separator )
Sets a new registry index separator value, which can then be used to determine index depth in place of the default dot syntax. This is provided for compatibility with programming logic that is not inherently compatible with the dot syntax, so that it may still work interchangeably with the registry. |
private
|
#
_initializeRegistry( $reset = false )
This must be called to initialize an instance of the registry at least one time, so all protected methods in this trait do so. The root registry index will be scoped to the fully qualified trait or class name that called registration. It will only distribute values in scope, maintaining privacy, and leaving it to the referencing construct to expose those values as needed. |
private
string
|
#
_extractRegistryLocalizedIndex( string $backreference )
Returns the root localized key reference from a supplied fully qualified method name |
private
type
|
#
_resolveRegistryKeyMapping( type $index, type $key )
Returns whether a specified index exists or not, honoring dot separated index notation. |
private
boolean
|
#
_checkRegistryKeyMapping( type $index, type $key )
Returns a determination as to whether or not a key exists in any provided subset, as defined in its dot separated notation (or literal representation, if no dos separation occurs) |
private
mixed
&
|
#
_getRegistryKeyMapping( array|object $index, scalar $key = null )
Returns the specified key from the registry, honoring dot separated index depth notation. |
private
boolean
|
#
_setRegistryKeyMapping( array|object & $index, scalar $key, mixed $value = array() , boolean $safe,… )
Sets a value in the registry by dot notated index reference. |
private
type
|
Methods used from oroboros\core\traits\utilities\logic\BackreferenceTrait
_convertBackReferenceNameSpaceToRelativeFilePath()
,
_filterBackReferenceTraitInheritance()
,
_findBackReferenceRealInheritanceLocation()
,
_getBackReference()
,
_getBackReferenceMatchingTraits()
,
_getBackReferenceTraceReferenceReflector()
Properties summary
private
array
|
$_registry_values
Primary container for private registry encapsulation. |
#
[ ]
|
private
string
|
$_registry_default_index_separator
the default registry index separator. This will be allowed to be overidden later, but that will need a lot of testing. |
#
'.'
|
private
string
|
$_registry_index_separator
the registry index separator. This will be allowed to be overidden later, but that will need a lot of testing. |
#
'.'
|