<?php


namespace CMSMSExt\core;


class fifo
{
  private $queue = [];
  
  public function enqueue($item)
  {
    $this->queue[] = $item;
    
    return $this;
  }
  
  public function dequeue()
  {
    if($this->isEmpty())
    {
      return NULL; // or throw an exception
    }
    
    return \array_shift($this->queue);
  }
  
  public function peek()
  {
    return \reset($this->queue);
  }
  
  public function isEmpty()
  {
    return empty($this->queue);
  }
  
  public function size()
  {
    return \count($this->queue);
  }
  
  public function reset()
  {
    $this->queue = [];
    
    return $this;
  }
}

?>