Code Duplication    Length = 18-19 lines in 2 locations

DataStructures/Lists/CircularLinkedList.php 1 location

@@ 410-427 (lines=18) @@
407
     *
408
     * @return mixed the data stored in the node.
409
     */
410
    private function deleteEnd() {
411
        $prev = $this->head;
412
        $current = $this->head;
413
        
414
        while($current !== $this->tail) {
415
            $prev = $current;
416
            $current = $current->next;
417
        }
418
        
419
        $temp = $current;
420
        $prev->next = &$this->head;
421
        $this->tail = &$prev;
422
        $current = null;
423
424
        $this->size--;
425
426
        return $temp->data;
427
    }
428
429
    /**
430
     * Deletes the first node of the list and returns it.

DataStructures/Lists/DoublyLinkedList.php 1 location

@@ 431-449 (lines=19) @@
428
     *
429
     * @return mixed the data stored in the node.
430
     */
431
    private function deleteEnd() {
432
        $prev = $this->head;
433
        $current = $this->head;
434
        
435
        while($current !== $this->tail) {
436
            $prev = $current;
437
            $current = $current->next;
438
        }
439
        
440
        $temp = $current;
441
        $prev->next = &$this->head;
442
        $this->head->prev = &$prev;
443
        $this->tail = &$prev;
444
        $current = null;
445
446
        $this->size--;
447
448
        return $temp->data;
449
    }
450
451
    /**
452
     * Deletes the first node of the list and returns it.