Code Duplication    Length = 18-19 lines in 2 locations

DataStructures/Lists/DoublyLinkedList.php 1 location

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

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.