Code Duplication    Length = 13-14 lines in 2 locations

DataStructures/Lists/DoublyLinkedList.php 1 location

@@ 298-310 (lines=13) @@
295
     *
296
     * @return mixed the data stored in the node.
297
     */
298
    protected function deleteBeginning() {
299
        // if only there is an element
300
        if($this->head->next === $this->head) {
301
            $temp = $this->head;
302
            $this->head = null;
303
        } else {
304
            $temp = $this->head;
305
            $this->head = &$this->head->next;
306
            $this->tail->next = &$this->head;
307
            
308
        }
309
        return $temp->data;
310
    }
311
312
    /**
313
     * Deletes at the specified position and returns the data stored.

DataStructures/Lists/CircularLinkedList.php 1 location

@@ 295-308 (lines=14) @@
292
    /**
293
     * {@inheritDoc}
294
     */
295
    protected function deleteBeginning() {
296
        // if only there is an element
297
        if($this->head->next === $this->head) {
298
            $temp = $this->head;
299
            $this->head = null;
300
            return $temp->data;
301
        }
302
        
303
        $temp = $this->head;
304
        $this->head = &$this->head->next;
305
        $this->tail->next = &$this->head;
306
307
        return $temp->data;
308
    }
309
310
    /**
311
     * {@inheritDoc}