PHP Class rcrowe\Hippy\Queue

Inheritance: implements rcrowe\Hippy\Message\SenderInterface, implements ArrayAccess, implements Iterator, implements Countable
Show file Open project: rcrowe/hippy Class Usage Examples

Protected Properties

Property Type Description
$container array The queue it's self. Just a simple array.

Public Methods

Method Description
add ( rcrowe\Hippy\Message\MessageInterface $message ) : integer Add an item to the queue.
count ( ) : integer Return the number of items currently in the queue.
current ( ) : string Returns the current element.
key ( ) : integer Returns the key of the current element.
next ( ) : void Moves the current position to the next queue.
offsetExists ( integer $offset ) : boolean Using the array interface, check whether an index in the queue exists.
offsetGet ( integer $offset ) : string | null Using the array interface, get an item from the queue.
offsetSet ( integer | null $offset, $value ) : void Set an index of the queue with an array interface.
offsetUnset ( integer $offset ) : boolean Using the array interface, remove an item from the queue.
remove ( integer $index = null ) : boolean Remove an item from the queue.
rewind ( ) : void Rewind back to the first element in the queue.
valid ( ) : boolean This method is called after Iterator::rewind() and Iterator::next() to check if the current position is valid.

Method Details

add() public method

The benefit of using the add function over using the queue as an array is that you are given back an index of the new item in the queue. This index allows you to remove it at a later stage if you choose.
See also: rcrowe\Hippy\Message\Queue::offsetSet()
public add ( rcrowe\Hippy\Message\MessageInterface $message ) : integer
$message rcrowe\Hippy\Message\MessageInterface
return integer Index of the new item in the queue.

count() public method

For example: count($queue)
public count ( ) : integer
return integer

current() public method

Returns the current element.
public current ( ) : string
return string

key() public method

Returns the key of the current element.
public key ( ) : integer
return integer

next() public method

Moves the current position to the next queue.
public next ( ) : void
return void

offsetExists() public method

For example isset($queue[0]);
public offsetExists ( integer $offset ) : boolean
$offset integer Index that you want to check the existence for.
return boolean Whether the index exists or not.

offsetGet() public method

For example echo $queue[0];
public offsetGet ( integer $offset ) : string | null
$offset integer Index that you want to get the value for.
return string | null If the index can not be found NULL is returned, else the value in the queue.

offsetSet() public method

For example $queue[] = 'string' or $queue[1] = 'string'. NOTE: Currently if adding a new item, even when passing an offset, the value will be appended and not interested at that index. If the index exists, then the old value will be removed and then the new value appended.
public offsetSet ( integer | null $offset, $value ) : void
$offset integer | null Index of the queue to remove/add.
return void

offsetUnset() public method

For example unset($queue[1]);
public offsetUnset ( integer $offset ) : boolean
$offset integer Index that you want to remove from the queue.
return boolean TRUE when the item is removed.

remove() public method

Remove an item from the queue.
See also: rcrowe\Campfire\Message\Queue::add()
public remove ( integer $index = null ) : boolean
$index integer Index for the message in the queue you want removed. NULL empties queue.
return boolean TRUE when the item is removed from the queue

rewind() public method

Rewind back to the first element in the queue.
public rewind ( ) : void
return void

valid() public method

This method is called after Iterator::rewind() and Iterator::next() to check if the current position is valid.
public valid ( ) : boolean
return boolean

Property Details

$container protected property

The queue it's self. Just a simple array.
protected array $container
return array