Code Duplication    Length = 17-17 lines in 2 locations

DataStructures/Lists/CircularLinkedList.php 1 location

@@ 315-331 (lines=17) @@
312
     * 
313
     * @return null if the head is null (or list is empty)
314
     */
315
    public function getAll() {
316
        if($this->head === null) {
317
            return;
318
        }
319
        
320
        if($this->head->next === $this->tail) {
321
            yield $this->head->data;
322
        } else {
323
            $current = $this->head;
324
            $i = 0;
325
            while($i < $this->size) {
326
                yield $current->data;
327
                $current = $current->next;
328
                $i++;
329
            }
330
        }
331
    }
332
    
333
    /**
334
     * Delete a node in the given position and returns it back.

DataStructures/Lists/DoublyLinkedList.php 1 location

@@ 234-250 (lines=17) @@
231
     * 
232
     * @return null if the head is null (or list is empty)
233
     */
234
    public function getAll() {
235
        if($this->head === null) {
236
            return;
237
        }
238
239
        if($this->head === $this->tail) {
240
            yield $this->head->data;
241
        } else {
242
            $current = $this->head;
243
            $i = 0;
244
            while($i < $this->size) {
245
                yield $current->data;
246
                $current = $current->next;
247
                $i++;
248
            }
249
        }
250
    }
251
252
    /**
253
     * Inserts data in the specified position.