Code Duplication    Length = 17-17 lines in 2 locations

DataStructures/Lists/DoublyLinkedList.php 1 location

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

DataStructures/Lists/CircularLinkedList.php 1 location

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