Elgg  Version 3.0
MemoryQueue.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Queue;
4 
16 class MemoryQueue implements \Elgg\Queue\Queue {
17 
18  /* @var array */
19  protected $queue = [];
20 
24  public function __construct() {
25  $this->queue = [];
26  }
27 
31  public function enqueue($item) {
32  return (bool) array_push($this->queue, $item);
33  }
34 
38  public function dequeue() {
39  return array_shift($this->queue);
40  }
41 
45  public function clear() {
46  $this->queue = [];
47  }
48 
52  public function size() {
53  return count($this->queue);
54  }
55 }
if(!$items) $item
Definition: delete.php:13
clear()
{Clear all items from the queue.void}
Definition: MemoryQueue.php:45
Queue interface.
Definition: Queue.php:16
dequeue()
{Remove an item from the queue.mixed}
Definition: MemoryQueue.php:38
FIFO queue that is memory based (not persistent)
Definition: MemoryQueue.php:16
size()
{Get the size of the queue.int}
Definition: MemoryQueue.php:52
enqueue($item)
{Add an item to the queue.Item to add to queue bool}
Definition: MemoryQueue.php:31
__construct()
Create a queue.
Definition: MemoryQueue.php:24