public function test_that_prev_stores_bucket_instance() { $bucket = new TerminalBucket(); $prev = new TerminalBucket(); $bucket->setPrev($prev); $this->assertSame($prev, $bucket->prev()); }
/** * Handles deep cloning * * @return void */ public function __clone() { $items = []; for ($this->rewind(); $this->valid(); $this->next()) { $items[] = $this->current(); } $this->head = new TerminalBucket(); $this->tail = new TerminalBucket(); $this->head->setNext($this->tail); $this->tail->setPrev($this->head); $this->current = $this->head; $this->count = 0; $this->offset = -1; $prev = $this->head; $next = $this->tail; foreach ($items as $item) { $this->insertBetween($item, $prev, $next); $prev = $this->current; } }
/** * Handles deep cloning * * @return void */ public function __clone() { $keys = []; $values = []; for ($this->rewind(); $this->valid(); $this->next()) { $values[] = $this->current(); $keys[] = $this->key(); } $this->head = new TerminalBucket(); $this->tail = new TerminalBucket(); $this->head->setNext($this->tail); $this->tail->setPrev($this->head); $this->current = $this->head; $this->count = 0; $this->offset = -1; $prev = $this->head; $next = $this->tail; for ($i = 0; $i < count($keys); $i++) { $this->insertBetween($keys[$i], $values[$i], $prev, $next); $prev = $this->current; } }