Code Duplication    Length = 21-22 lines in 3 locations

src/Graviton/DocumentBundle/DependencyInjection/Compiler/Utils/DocumentMap.php 3 locations

@@ 223-244 (lines=22) @@
220
     * @param Finder $finder Mapping finder
221
     * @return array
222
     */
223
    private function loadDoctrineClassMap(Finder $finder)
224
    {
225
        $classMap = [];
226
        foreach ($finder as $file) {
227
            $document = new \DOMDocument();
228
            $document->load($file);
229
230
            $xpath = new \DOMXPath($document);
231
            $xpath->registerNamespace('doctrine', 'http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping');
232
233
            $classMap = array_reduce(
234
                iterator_to_array($xpath->query('//*[self::doctrine:document or self::doctrine:embedded-document]')),
235
                function (array $classMap, \DOMElement $element) {
236
                    $classMap[$element->getAttribute('name')] = $element;
237
                    return $classMap;
238
                },
239
                $classMap
240
            );
241
        }
242
243
        return $classMap;
244
    }
245
246
    /**
247
     * Load serializer class map
@@ 252-272 (lines=21) @@
249
     * @param Finder $finder Mapping finder
250
     * @return array
251
     */
252
    private function loadSerializerClassMap(Finder $finder)
253
    {
254
        $classMap = [];
255
        foreach ($finder as $file) {
256
            $document = new \DOMDocument();
257
            $document->load($file);
258
259
            $xpath = new \DOMXPath($document);
260
261
            $classMap = array_reduce(
262
                iterator_to_array($xpath->query('//class')),
263
                function (array $classMap, \DOMElement $element) {
264
                    $classMap[$element->getAttribute('name')] = $element;
265
                    return $classMap;
266
                },
267
                $classMap
268
            );
269
        }
270
271
        return $classMap;
272
    }
273
274
    /**
275
     * Load schema class map
@@ 319-340 (lines=22) @@
316
     * @param Finder $finder Mapping finder
317
     * @return array
318
     */
319
    private function loadValidationClassMap(Finder $finder)
320
    {
321
        $classMap = [];
322
        foreach ($finder as $file) {
323
            $document = new \DOMDocument();
324
            $document->load($file);
325
326
            $xpath = new \DOMXPath($document);
327
            $xpath->registerNamespace('constraint', 'http://symfony.com/schema/dic/constraint-mapping');
328
329
            $classMap = array_reduce(
330
                iterator_to_array($xpath->query('//constraint:class')),
331
                function (array $classMap, \DOMElement $element) {
332
                    $classMap[$element->getAttribute('name')] = $element;
333
                    return $classMap;
334
                },
335
                $classMap
336
            );
337
        }
338
339
        return $classMap;
340
    }
341
342
    /**
343
     * Get serializer fields