Code Duplication    Length = 11-12 lines in 3 locations

src/OptimizedPathMappingRepository.php 2 locations

@@ 217-227 (lines=11) @@
214
     *
215
     * @return RegexFilterIterator The iterator of paths.
216
     */
217
    private function getChildIterator(PuliResource $resource)
218
    {
219
        $staticPrefix = rtrim($resource->getPath(), '/').'/';
220
        $regExp = '~^'.preg_quote($staticPrefix, '~').'[^/]+$~';
221
222
        return new RegexFilterIterator(
223
            $regExp,
224
            $staticPrefix,
225
            new ArrayIterator($this->store->keys())
226
        );
227
    }
228
229
    /**
230
     * Returns a recursive iterator for the children paths under a given path.
@@ 236-246 (lines=11) @@
233
     *
234
     * @return RegexFilterIterator The iterator of paths.
235
     */
236
    private function getRecursivePathChildIterator($path)
237
    {
238
        $staticPrefix = rtrim($path, '/').'/';
239
        $regExp = '~^'.preg_quote($staticPrefix, '~').'.+$~';
240
241
        return new RegexFilterIterator(
242
            $regExp,
243
            $staticPrefix,
244
            new ArrayIterator($this->store->keys())
245
        );
246
    }
247
248
    /**
249
     * Returns an iterator for a glob.

src/InMemoryRepository.php 1 location

@@ 277-288 (lines=12) @@
274
     *
275
     * @return RegexFilterIterator The iterator.
276
     */
277
    private function getChildIterator(PuliResource $resource)
278
    {
279
        $staticPrefix = rtrim($resource->getPath(), '/').'/';
280
        $regExp = '~^'.preg_quote($staticPrefix, '~').'[^/]+$~';
281
282
        return new RegexFilterIterator(
283
            $regExp,
284
            $staticPrefix,
285
            new ArrayIterator($this->resources),
286
            RegexFilterIterator::FILTER_KEY
287
        );
288
    }
289
290
    /**
291
     * Returns an iterator for a glob.