$conf
$conf : \Phabstractic\Features\Zend\Config\Config
The objects configuration object
Should be an instance of Zend/Config
Set Class - Defines A Set Data Structure
A set is a collection of values that are unique. In mathematical terms it is an implementation of a finite set. Usually you test if something exists or doesn't exist inside the set. You can also set up operations on sets themselves, much like an array map. You can also easily perform unions, intersections, and many operations traditional to set theory and the set data type.
CHANGELOG
1.0: Documented Set - March 5th, 2013 1.1: Added Closures to array set operations - October 7th, 2013 2.0: Refactored and included into Primus/Falcraft - April 10th, 2015 3.0: reorganized namespaces edited returnUniqueByReference calls to actually use references set only unique if unique option is set now !!! reformatted for inclusion in phabstractic - July 10th, 2016 3.0.1: implements configurationinterface - July 13th, 2016
configure(array|string|\Phabstractic\Features\Zend\Config\Config $configuration, string $format = null, mixed $context = null) : boolean
Configure An Object
Expects an array for configuration however, you can also pass it a filepath where it will read the information from a file automatically detecting the format using the file extension. You can also pass a Zend/Config object already made.
You can also pass a format specifier (forced format) for use in a if $configuration is a string formatted with such information. E.G. to load from a string in the format ini:
$this->configure($configString, 'ini');
The $context argument is used for any additional reader constructor information, such as the constructor for the 'yaml' format.
NOTE: You can override/extend the classes used for reading formats by identifying an additional array in the property $this->configReaders. This will merge with the standard formats array.
array|string|\Phabstractic\Features\Zend\Config\Config | $configuration | The objects configuration information. |
string | $format | The forced format, or format for configuration string |
mixed | $context | Any additional information for a reader constructor, such as needed for the YAML format. |
True if instantiated
saveSettings(string $file, \Phabstractic\Features\Zend\Config\Writer\WriterInterface $writer = null, boolean $exclusive = true, mixed $context = null)
Save an Object's Configuration to a File
Takes an objects $conf property and writes the information contained therein to a file with a format automatically specified by the filename.
It is possible to retrieve a string of a particular format from this method by specifying the filename '#string' with an extension indicating the desired format, such as '#string.json'.
The $context argument is used for any additional reader constructor information, such as the constructor for the 'yaml' format.
NOTE: You can override/extend the classes used for writing formats by identifying an additional array in the property $this->configWriters. This will merge with the standard formats array.
string | $file | The file path to write to, or '#string.ext' |
\Phabstractic\Features\Zend\Config\Writer\WriterInterface | $writer | The optional writer object supplied to use (such as a MySQL writer) |
boolean | $exclusive | Argument provided to toFile(), file exclusive lock when writing |
mixed | $context | Any additionla writer constructor information (YAML) |
getSettings(string $format, $context = null) : string|boolean
Retrieve an Object's Configuration Information As String
This is a shortcut to ::saveSettings() which specifies a format and forces the return of a string, using the #string.ext filename -see documentation for ::saveSettings()-
string | $format | The format to return, must be supported by ::saveSettings(), use $this->configWriters to support additional formats. |
$context |
The formatted string, or false otherwise
processSettings(\Phabstractic\Features\Zend\Config\Processor\ProcessorInterface $processor)
Process an Object's Configuration
This uses a Zend\Config\Processor implementation to process the configuration information, such as constants. The processor must be supplied and implement ProcessorInterface
NOTE: Edits the $conf object in place.
\Phabstractic\Features\Zend\Config\Processor\ProcessorInterface | $processor | The given processor object |
__construct(array $values = array(), array|\Phabstractic\Data\Types\Zend\Config\Config|string $options = array())
Set Construction
Sets the data member to the given array.
NOTE: A set can contain any type of data, even mixed data. This means that a set might contain integers, objects, and anything else storable in a variable all together simultaneously.
IMPORTANT: If keys are specified in the initial array then these keys are used as their identifications.
Options -
'unique' => bool, do we check the incoming data for uniqueness? If data is not unique an exception is raised. 'strict' => bool, do we raise exceptions when the set is used improperly, such as removing a value that doesn't exist? 'reference' => bool, do we add in constructor by reference? defaults to true
array | $values | The values of the set |
array|\Phabstractic\Data\Types\Zend\Config\Config|string | $options | See options above. |
retrieveReference(mixed $identifier) : mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None;
If the value is in the set, this retrieves a reference to it
This only works if the set is considered unique
mixed | $identifier | The identifier returned by the add function |
if strict
equal(\Phabstractic\Data\Types\Resource\SetInterface $S1, \Phabstractic\Data\Types\Resource\SetInterface $S2) : boolean
Is S1 Equal to S2?
This static function converts the sets to plain arrays, but compares them using the arrayUtilities function.
\Phabstractic\Data\Types\Resource\SetInterface | $S1 | |
\Phabstractic\Data\Types\Resource\SetInterface | $S2 |
fold(callable $F, \Phabstractic\Data\Types\Set $S) : mixed
Apply a function to each element of the set, reducing to a single function
"returns the value A|S| after applying Ai+1 := F(Ai, e) for each element e of S."
callable | $F | The applicable function. |
\Phabstractic\Data\Types\Set | $S | The Set to fold |
The value resulting from the 'fold' (array_reduce)
filter(callable $F, \Phabstractic\Data\Types\Set $S) : array
Returns only elements that satisfy a 'predicate'
The predicate here is a function that returns true or false on any given item "returns the subset containing all elements of S that satisfy a given predicate P."
callable | $F | The applicable predicate function. |
\Phabstractic\Data\Types\Set | $S | The Set to filter |
The filtered aray
map(callable $F, \Phabstractic\Data\Types\Set $S) : array
Apply a function to each element of the set
"returns the set of distinct values resulting from applying function F to each element of S."
callable | $F | The applicable function. |
\Phabstractic\Data\Types\Set | $S | The Set to map |
The resulting distinct set
walk(\Phabstractic\Data\Types\Resource\SetInterface $S, callable $F, mixed $D) : boolean
Walk (non-recursively) the array
Applies the given function, plus any additional arguments ($args) past the given function argument to each element of the set.
Note: Unlike Map, this operates on a reference of the set
\Phabstractic\Data\Types\Resource\SetInterface | $S | |
callable | $F | the applicablt function |
mixed | $D | the user data |
True on Success, False otherwise
build(array $values = array()) : \Phabstractic\Data\Types\Set
Create a set from an array
Just hands back a Set created from a given array "creates a set structure with values x1,x2,…,xn."
array | $values | The values of the set (which are 'uniqued' in the construction) |
subset(\Phabstractic\Data\Types\Set $S, \Phabstractic\Data\Types\Set $T) : boolean
Subset
"a predicate that tests whether the set S is a subset of set T."
This function tests whether all elements of S are in T
\Phabstractic\Data\Types\Set | $S | The first set |
\Phabstractic\Data\Types\Set | $T | The comparison/parent set |
checkUniqueValues(array $values = array()) : boolean
Check an array for unique values
Useful for 'strict' option to warn of incoming duplicate entries
array | $values | The array to check |
When a value is not unique in the array if configured strict
Successful?