Code Duplication    Length = 18-19 lines in 2 locations

DataStructures/Lists/CircularLinkedList.php 1 location

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

DataStructures/Lists/DoublyLinkedList.php 1 location

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