Code Duplication    Length = 11-12 lines in 3 locations

src/OptimizedPathMappingRepository.php 2 locations

@@ 238-248 (lines=11) @@
235
     *
236
     * @return RegexFilterIterator The iterator of paths.
237
     */
238
    private function getChildIterator(PuliResource $resource)
239
    {
240
        $staticPrefix = rtrim($resource->getPath(), '/').'/';
241
        $regExp = '~^'.preg_quote($staticPrefix, '~').'[^/]+$~';
242
243
        return new RegexFilterIterator(
244
            $regExp,
245
            $staticPrefix,
246
            new ArrayIterator($this->store->keys())
247
        );
248
    }
249
250
    /**
251
     * Returns a recursive iterator for the children paths under a given path.
@@ 257-267 (lines=11) @@
254
     *
255
     * @return RegexFilterIterator The iterator of paths.
256
     */
257
    private function getRecursivePathChildIterator($path)
258
    {
259
        $staticPrefix = rtrim($path, '/').'/';
260
        $regExp = '~^'.preg_quote($staticPrefix, '~').'.+$~';
261
262
        return new RegexFilterIterator(
263
            $regExp,
264
            $staticPrefix,
265
            new ArrayIterator($this->store->keys())
266
        );
267
    }
268
269
    /**
270
     * Returns an iterator for a glob.

src/InMemoryRepository.php 1 location

@@ 307-318 (lines=12) @@
304
     *
305
     * @return RegexFilterIterator The iterator.
306
     */
307
    private function getChildIterator(PuliResource $resource)
308
    {
309
        $staticPrefix = rtrim($resource->getPath(), '/').'/';
310
        $regExp = '~^'.preg_quote($staticPrefix, '~').'[^/]+$~';
311
312
        return new RegexFilterIterator(
313
            $regExp,
314
            $staticPrefix,
315
            new ArrayIterator($this->resources),
316
            RegexFilterIterator::FILTER_KEY
317
        );
318
    }
319
320
    /**
321
     * Returns an iterator for a glob.