for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @author Igor Pomiluyko [email protected]
* @license MIT
*/
namespace WS\Utils\Collections;
use RuntimeException;
use WS\Utils\Collections\Iterator\Iterator;
use WS\Utils\Collections\Iterator\IteratorFactory;
class ArrayQueue extends AbstractCollection implements Queue, IndexIterable
{
use RemoveTraverseTrait;
public function offer($element): bool
return $this->add($element);
}
public function poll()
if ($this->isEmpty()) {
throw new RuntimeException('Queue is empty');
$this->pointer--;
return array_shift($this->elements);
public function peek()
return $this->elements[0];
public function stream(): Stream
return new SerialStream($this);
public function getIndexIterator(): Iterator
return IteratorFactory::directSequence($this->size());
protected function afterElementAdd($element): void
protected function afterElementsSet(): void