Code Duplication    Length = 18-19 lines in 2 locations

DataStructures/Lists/CircularLinkedList.php 1 location

@@ 327-344 (lines=18) @@
324
     *
325
     * @return mixed the data stored in the node.
326
     */
327
    private function deleteEnd() {
328
        $prev = $this->head;
329
        $current = $this->head;
330
        
331
        while($current !== $this->tail) {
332
            $prev = $current;
333
            $current = $current->next;
334
        }
335
        
336
        $temp = $current;
337
        $prev->next = &$this->head;
338
        $this->tail = &$prev;
339
        $current = null;
340
341
        $this->size--;
342
343
        return $temp->data;
344
    }
345
346
    /**
347
     * Deletes the first node of the list and returns it.

DataStructures/Lists/DoublyLinkedList.php 1 location

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