Elgg  Version 4.3
MemoryQueue.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Queue;
4 
11 class MemoryQueue implements \Elgg\Queue\Queue {
12 
13  /* @var array */
14  protected $queue = [];
15 
19  public function __construct() {
20  $this->queue = [];
21  }
22 
26  public function enqueue($item) {
27  return (bool) array_push($this->queue, $item);
28  }
29 
33  public function dequeue() {
34  return array_shift($this->queue);
35  }
36 
40  public function clear() {
41  $this->queue = [];
42  }
43 
47  public function size() {
48  return count($this->queue);
49  }
50 }
if(!$items) $item
Definition: delete.php:13
clear()
{Clear all items from the queue.void}
Definition: MemoryQueue.php:40
Queue interface.
Definition: Queue.php:11
dequeue()
{Remove an item from the queue.mixed}
Definition: MemoryQueue.php:33
FIFO queue that is memory based (not persistent)
Definition: MemoryQueue.php:11
size()
{Get the size of the queue.int}
Definition: MemoryQueue.php:47
enqueue($item)
{Add an item to the queue.Item to add to queue bool}
Definition: MemoryQueue.php:26
__construct()
Create a queue.
Definition: MemoryQueue.php:19