/** * Add value * * @param $value * @return mixed */ public function add($value) { $node = $this->nodeFactory->create($value); $this->length++; if (!$this->current) { $this->current = $node; $this->last = $node; } else { $this->last->setRight($node); $this->last = $node; } }
/** * Add value * * @param string $key * @param $value * @return mixed */ public function add(string $key, $value) { $item = $this->itemFactory->create($key, $value); $node = $this->nodeFactory->create($item); $this->length++; if (!$this->first) { $this->first = $node; $this->current = $node; $this->last = $node; } else { $this->last->setRight($node); $node->setLeft($this->last); $this->last = $node; } }