Code Duplication    Length = 17-17 lines in 2 locations

DataStructures/Lists/CircularLinkedList.php 1 location

@@ 264-280 (lines=17) @@
261
     * 
262
     * @return null if the head is null (or list is empty)
263
     */
264
    public function getAll() {
265
        if($this->head === null) {
266
            return;
267
        }
268
        
269
        if($this->head->next === $this->tail) {
270
            yield $this->head->data;
271
        } else {
272
            $current = $this->head;
273
            $i = 0;
274
            while($i < $this->size) {
275
                yield $current->data;
276
                $current = $current->next;
277
                $i++;
278
            }
279
        }
280
    }
281
    
282
    /**
283
     * Delete a node in the given position and returns it back.

DataStructures/Lists/DoublyLinkedList.php 1 location

@@ 179-195 (lines=17) @@
176
     * 
177
     * @return null if the head is null (or list is empty)
178
     */
179
    public function getAll() {
180
        if($this->head === null) {
181
            return;
182
        }
183
184
        if($this->head === $this->tail) {
185
            yield $this->head->data;
186
        } else {
187
            $current = $this->head;
188
            $i = 0;
189
            while($i < $this->size) {
190
                yield $current->data;
191
                $current = $current->next;
192
                $i++;
193
            }
194
        }
195
    }
196
197
    /**
198
     * Inserts data in the specified position.