Code Duplication    Length = 17-17 lines in 2 locations

DataStructures/Lists/CircularLinkedList.php 1 location

@@ 246-262 (lines=17) @@
243
     * 
244
     * @return null if the head is null (or list is empty)
245
     */
246
    public function getAll() {
247
        if($this->head === null) {
248
            return;
249
        }
250
        
251
        if($this->head->next === $this->tail) {
252
            yield $this->head->data;
253
        } else {
254
            $current = $this->head;
255
            $i = 0;
256
            while($i < $this->size) {
257
                yield $current->data;
258
                $current = $current->next;
259
                $i++;
260
            }
261
        }
262
    }
263
264
    /**
265
     * {@inheritDoc}

DataStructures/Lists/DoublyLinkedList.php 1 location

@@ 196-212 (lines=17) @@
193
     * 
194
     * @return null if the head is null (or list is empty)
195
     */
196
    public function getAll() {
197
        if($this->head === null) {
198
            return;
199
        }
200
201
        if($this->head === $this->tail) {
202
            yield $this->head->data;
203
        } else {
204
            $current = $this->head;
205
            $i = 0;
206
            while($i < $this->size) {
207
                yield $current->data;
208
                $current = $current->next;
209
                $i++;
210
            }
211
        }
212
    }
213
214
    /**
215
     * {@inheritDoc}