Code Duplication    Length = 13-14 lines in 2 locations

DataStructures/Lists/CircularLinkedList.php 1 location

@@ 267-280 (lines=14) @@
264
    /**
265
     * {@inheritDoc}
266
     */
267
    protected function deleteBeginning() {
268
        // if only there is an element
269
        if($this->head->next === $this->head) {
270
            $temp = $this->head;
271
            $this->head = null;
272
            return $temp->data;
273
        }
274
        
275
        $temp = $this->head;
276
        $this->head = &$this->head->next;
277
        $this->tail->next = &$this->head;
278
279
        return $temp->data;
280
    }
281
282
    /**
283
     * {@inheritDoc}

DataStructures/Lists/DoublyLinkedList.php 1 location

@@ 269-281 (lines=13) @@
266
     *
267
     * @return mixed the data stored in the node.
268
     */
269
    protected function deleteBeginning() {
270
        // if only there is an element
271
        if($this->head->next === $this->head) {
272
            $temp = $this->head;
273
            $this->head = null;
274
        } else {
275
            $temp = $this->head;
276
            $this->head = &$this->head->next;
277
            $this->tail->next = &$this->head;
278
            
279
        }
280
        return $temp->data;
281
    }
282
283
    /**
284
     * Deletes at the specified position and returns the data stored.