Code Duplication    Length = 18-19 lines in 2 locations

DataStructures/Lists/CircularLinkedList.php 1 location

@@ 359-376 (lines=18) @@
356
     *
357
     * @return mixed the data stored in the node.
358
     */
359
    private function deleteEnd() {
360
        $prev = $this->head;
361
        $current = $this->head;
362
        
363
        while($current !== $this->tail) {
364
            $prev = $current;
365
            $current = $current->next;
366
        }
367
        
368
        $temp = $current;
369
        $prev->next = &$this->head;
370
        $this->tail = &$prev;
371
        $current = null;
372
373
        $this->size--;
374
375
        return $temp->data;
376
    }
377
378
    /**
379
     * Deletes the first node of the list and returns it.

DataStructures/Lists/DoublyLinkedList.php 1 location

@@ 376-394 (lines=19) @@
373
     *
374
     * @return mixed the data stored in the node.
375
     */
376
    private function deleteEnd() {
377
        $prev = $this->head;
378
        $current = $this->head;
379
        
380
        while($current !== $this->tail) {
381
            $prev = $current;
382
            $current = $current->next;
383
        }
384
        
385
        $temp = $current;
386
        $prev->next = &$this->head;
387
        $this->head->prev = &$prev;
388
        $this->tail = &$prev;
389
        $current = null;
390
391
        $this->size--;
392
393
        return $temp->data;
394
    }
395
396
    /**
397
     * Deletes the first node of the list and returns it.