Code Duplication    Length = 16-17 lines in 2 locations

DataStructures/Lists/CircularLinkedList.php 1 location

@@ 339-354 (lines=16) @@
336
     *
337
     * @return mixed the data stored in the node.
338
     */
339
    protected function deleteEnd() {
340
        $prev = $this->head;
341
        $current = $this->head;
342
        
343
        while($current !== $this->tail) {
344
            $prev = $current;
345
            $current = $current->next;
346
        }
347
        
348
        $temp = $current;
349
        $prev->next = &$this->head;
350
        $this->tail = &$prev;
351
        $current = null;
352
353
        return $temp->data;
354
    }
355
356
    /**
357
     * Converts/exports the list content into array type.

DataStructures/Lists/DoublyLinkedList.php 1 location

@@ 342-358 (lines=17) @@
339
     *
340
     * @return mixed the data stored in the node.
341
     */
342
    protected function deleteEnd() {
343
        $prev = $this->head;
344
        $current = $this->head;
345
        
346
        while($current !== $this->tail) {
347
            $prev = $current;
348
            $current = $current->next;
349
        }
350
        
351
        $temp = $current;
352
        $prev->next = &$this->head;
353
        $this->head->prev = &$prev;
354
        $this->tail = &$prev;
355
        $current = null;
356
357
        return $temp->data;
358
    }
359
    
360
    /**
361
     * Converts/exports the list content into array type.