private function reindex(int $capacity): void
    {
        $temp = [];
        for ($i = 0; $i < $this->count; $i++) {
            $temp[$i] = $this->items[($i + $this->front) % $this->cap];
        }
        $this->items = $temp;
        $this->cap = $capacity;
        $this->front = 0;
        $this->end = $this->count;
    }
private function reindex(int $capacity): void
    {
        $temp = [];
        for ($i = 0; $i < $this->count; $i++) {
            $temp[$i] = $this->items[($i + $this->front) % $this->cap];
        }
        $this->items = $temp;
        $this->cap = $capacity;
        $this->front = 0;
        $this->end = $this->count;
    }
private function reindex ( int $ capacity ) : void { $ temp = [ ] ; for ( $ i = 0 ; $ i < $ this -> count ; $ i ++ ) { $ temp [ $ i ] = $ this -> items [ ( $ i + $ this -> front ) % $ this -> cap ] ; } $ this -> items = $ temp ; $ this -> cap = $ capacity ; $ this -> front = 0 ; $ this -> end = $ this -> count ; }
Re-indexes the underlying array

This is needed to keep wrapping under control. Using direct indices
allows operations in constant amortized time instead of O(n).

Using array_(un)shift is easier, but requires re-indexing the array
every time during the enqueue or dequeue operation.

@param int $capacity The new capacity

@return void
Re - indexes the underlying array