Code Duplication    Length = 17-17 lines in 2 locations

DataStructures/Lists/CircularLinkedList.php 1 location

@@ 274-290 (lines=17) @@
271
     * 
272
     * @return null if the head is null (or list is empty)
273
     */
274
    public function getAll() {
275
        if($this->head === null) {
276
            return;
277
        }
278
        
279
        if($this->head->next === $this->tail) {
280
            yield $this->head->data;
281
        } else {
282
            $current = $this->head;
283
            $i = 0;
284
            while($i < $this->size) {
285
                yield $current->data;
286
                $current = $current->next;
287
                $i++;
288
            }
289
        }
290
    }
291
292
    /**
293
     * Deletes at the beginnig of the list and returns the data stored.

DataStructures/Lists/DoublyLinkedList.php 1 location

@@ 229-245 (lines=17) @@
226
     * 
227
     * @return null if the head is null (or list is empty)
228
     */
229
    public function getAll() {
230
        if($this->head === null) {
231
            return;
232
        }
233
234
        if($this->head === $this->tail) {
235
            yield $this->head->data;
236
        } else {
237
            $current = $this->head;
238
            $i = 0;
239
            while($i < $this->size) {
240
                yield $current->data;
241
                $current = $current->next;
242
                $i++;
243
            }
244
        }
245
    }
246
247
    /**
248
     * {@inheritDoc}