\Phabstractic\Data\TypesQueue

Queue Class - Defines a Queue Data Structure

A queue is a basic First In First Out structure. The The first thing you put in it, is the first thing you get from it.

CHANGELOG

1.0: Created Queue - May 10th, 2013 1.1: Updated Documentation, Added Throw Clarification - October 7th, 2013 2.0: Refactored and re-formatted for inclusion in primus - April 11th, 2015 2.1: Added strict checking to errors and error proofed roll - April 14th, 2015 3.0: Added and refactored for inclusion in primus2 - August 31st, 2015 3.1: Refined array functions, fixed count function - September 4th, 2015 4.0: reformatted for inclusion in phabstractic - July 21st, 2016 4.0.1: implements configurationinterface - July 31st, 2016

Summary

Methods
Properties
Constants
configure()
saveSettings()
getSettings()
processSettings()
__construct()
top()
topReference()
push()
pushReference()
pop()
popReference()
index()
indexReference()
count()
isEmpty()
clear()
remove()
getList()
exchange()
duplicate()
roll()
offsetSet()
offsetGet()
offsetUnset()
offsetExists()
bottom()
bottomReference()
getQueue()
__debugInfo()
No public properties found
No constants found
No protected methods found
$conf
$list
N/A
No private methods found
No private properties found
N/A

Properties

$conf

$conf : \Phabstractic\Features\Zend\Config\Config

The objects configuration object

Should be an instance of Zend/Config

Type

\Phabstractic\Features\Zend\Config\Config — The object configuration info

$list

$list : array

The internal list member

Generally an array, but can be overridden by a child class to be anything.

Type

array — The list data structure array

Methods

configure()

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.

Parameters

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.

Returns

boolean —

True if instantiated

saveSettings()

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.

Parameters

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()

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()-

Parameters

string $format

The format to return, must be supported by ::saveSettings(), use $this->configWriters to support additional formats.

$context

Returns

string|boolean —

The formatted string, or false otherwise

processSettings()

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.

Parameters

\Phabstractic\Features\Zend\Config\Processor\ProcessorInterface $processor

The given processor object

__construct()

__construct(mixed  $data = null, array  $options = array()) 

Override the constructor so that we have our own configurations

Populates the internal member array

Creates an empty list if no parameter given.

Parameters

mixed $data

The list data

array $options

The class options

top()

top() : mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None

Retrieve the 'top' of the list

Note: Does not 'pop' the value off the list

Throws

\Phabstractic\Data\Types\Phabstractic\Data\Types\Exception\RangeException

if no top exists

Returns

mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None —

'Top' Value of List otherwise

topReference()

topReference() : mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None

Return the 'top' of the list as a reference

Note: Does not 'pop' the value off the list

Throws

\Phabstractic\Data\Types\Phabstractic\Data\Types\Exception\RangeException

if no top exists

Returns

mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None —

'Top' Values as Reference of List

push()

push() : integer

Push a value on to the list - LIFO

However that is in implementation (lifo/fifo/etc)

Returns

integer —

Count of new list

pushReference()

pushReference(  $a) : integer

Push a reference on to the list - LIFO

However that is in implementation (lifo/fifo/etc)

Parameters

$a

Returns

integer —

Count of new list

pop()

pop() : mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None

Returns the 'top' value and pops the value off the list

However that is in implementation (lifo/fifo/etc)

Throws

\Phabstractic\Data\Types\Exception\RangeException

if the top doesn't exist

Returns

mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None —

The 'top' value of the list

popReference()

popReference() : mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None

Returns the 'top' value as reference, pops value off

However that is in implementation (lifo/fifo/etc)

Returns

mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None —

The 'top' value as reference of the list

index()

index(integer  $i) : mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None

Return the $i'th element of the list

This should be used carefully, as implementation varies

Parameters

integer $i

The numerical index into the list

Throws

\Phabstractic\Data\Types\Phabstractic\Data\Types\Exception\RangeException

If index is out of well... range.

Returns

mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None —

The value found at index of list: list[index]

indexReference()

indexReference(integer  $i) : mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None

Return the $i'th element of the list as a reference

Parameters

integer $i

The numerical index into the list

Throws

\Phabstractic\Data\Types\Phabstractic\Data\Types\Exception\RangeException

If index is out of well... range.

Returns

mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None —

The value at the list's numerical index as a reference

count()

count() : integer

Return the size of the list

Returns

integer —

The number of elements in the list currently

isEmpty()

isEmpty() : boolean

Return whether the list is empty currently

Returns

boolean —

Whether ths list is empty or not

clear()

clear() : \Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\Resource\AbstractList

Clear all the values from the list

Be careful!

Returns

\Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\Resource\AbstractList —

For chaining

remove()

remove(mixed  $value) : \Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\Resource\AbstractList

Remove a value out of the list

This is just in case we want to remove something out of order.

Only removes the first occurance of value

Parameters

mixed $value

The value to remove

Returns

\Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\Resource\AbstractList —

For chaining

getList()

getList() : array

Retrieve the list element of the list

Implementation varies return value

Returns

array —

The current internal list member

exchange()

exchange() : \Phabstractic\Data\Types\Phabstractic\Data\Types\Resource\AbstractList

Exchange the two top elements of the list

Returns

\Phabstractic\Data\Types\Phabstractic\Data\Types\Resource\AbstractList —

For chaining

duplicate()

duplicate() : \Phabstractic\Data\Types\Phabstractic\Data\Types\Resource\AbstractList

Duplicate the value at the top of the list

Note: Adds the duplicate to the front of the list

Returns

\Phabstractic\Data\Types\Phabstractic\Data\Types\Resource\AbstractList —

For chaining

roll()

roll(  $c) 

'Rolls' the list like one might 'roll' a wheel.

Negative values roll the list the opposite direction positive values roll the list.

Note: Edits the list in place, does not return copy of list

EX:

12345 might become 34512

NOTE: May not be object friendly, depending on array

Parameters

$c

Throws

\Phabstractic\Data\Types\Phabstractic\Data\Types\Exception\InvalidArgumentException

If argument isn't integer

offsetSet()

offsetSet(integer  $key, mixed  $value) : integer|\Phabstractic\Data\Types\Phabstractic\Data\Types\None

Set the offset in the list to the provided value

Parameters

integer $key

The index to the list item

mixed $value

The value to set to

Throws

\Phabstractic\Data\Types\Phabstractic\Data\Types\Exception\RangeException

if the value is not a queue index

Returns

integer|\Phabstractic\Data\Types\Phabstractic\Data\Types\None —

New number of list elements

offsetGet()

offsetGet(integer  $key) : mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None

Retrieve the value in the list at the provided index

Parameters

integer $key

The index to the list item

Throws

\Phabstractic\Data\Types\Phabstractic\Data\Types\Exception\RangeException

if the value is not a queue index

Returns

mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None —

The value at the list index

offsetUnset()

offsetUnset(integer  $key) : boolean

Unset the index and value on the list

Note: Like the unset method, this throws no error if the index doesn't exist.

Parameters

integer $key

The index to the list item

Returns

boolean —

False if the index is improper, or not numeric, true otherwise

offsetExists()

offsetExists(integer  $key) : boolean

Does the given key exist in the list?

Note: This method also returns false if the key is out of range

Parameters

integer $key

The index into the queue

Returns

boolean —

Existing?

bottom()

bottom() : mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None

Retrieve the 'bottom' of the list

Note: Does not 'shift' the value off the list

Throws

\Phabstractic\Data\Types\Phabstractic\Data\Types\Exception\RangeException

if no top exists

Returns

mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None —

'Top' Value of List otherwise

bottomReference()

bottomReference() : mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None

Return the 'top' of the list as a reference

Note: Does not 'pop' the value off the list

Throws

\Phabstractic\Data\Types\Phabstractic\Data\Types\Exception\RangeException

if no top exists

Returns

mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None —

'Top' Values as Reference of List

getQueue()

getQueue() : array

Returns the queue as an array

Note: Returns internal array

Returns

array —

The internal queue array

__debugInfo()

__debugInfo() 

Debug Info (var_dump)

Display debug info

Requires PHP 5.6+