GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#62)
by Simone
02:35
created

MapBuilder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Mado\QueryBundle\Component\Meta;
4
5
use Doctrine\ORM\EntityManager;
6
use Doctrine\ORM\Mapping\ClassMetadata;
7
8
class MapBuilder implements RelationDatamapper
9
{
10
    private $manager;
11
12
    private $map = [];
13
14
    public function __construct(EntityManager $manager)
15
    {
16
        $this->manager = $manager;
17
    }
18
19
    public function getMap() : array
20
    {
21
        $this->rebuildRelationMap();
22
23
        return $this->map;
24
    }
25
26
    public static function relations(ClassMetadata $classMetadata)
27
    {
28
        $encoded = json_encode($classMetadata);
29
        $decoded = json_decode($encoded, true);
30
        $relations = $decoded['associationMappings'];
31
32
        $relMap = [];
33
34
        foreach ($relations as $name => $meta) {
35
            $relMap[$name] = $meta['targetEntity'];
36
        }
37
38
        return $relMap;
39
    }
40
41
    public function rebuildRelationMap()
42
    {
43
        $allMetadata = $this->manager
44
            ->getMetadataFactory()
45
            ->getAllMetadata();
46
47
        foreach ($allMetadata as $singleEntityMetadata) {
48
            $this->map[$singleEntityMetadata->getName()]['relations'] = self::relations($singleEntityMetadata);
49
        }
50
    }
51
}
52