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
Push — feature/2.2/provide_field_usab... ( 968349...01a28f )
by Simone
02:37
created

CurrentMetaData::justEntitiesMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Mado\QueryBundle\Component\Sherlock;
4
5
use Doctrine\ORM\EntityManagerInterface;
6
use Mado\QueryBundle\Dictionary;
7
8
class CurrentMetaData
9
{
10
    private $metadata;
11
12
    private $manager;
13
14
    private $currentMetadata;
15
16 1
    private function __construct(EntityManagerInterface $manager)
17
    {
18 1
        $this->manager = $manager;
19
20 1
        $metadata = $this->manager
21 1
            ->getMetaDataFactory()
22 1
            ->getAllMetaData();
23
24 1
        $this->metadata = $metadata;
25 1
    }
26
27 1
    public static function fromEntityManager(EntityManagerInterface $manager) : CurrentMetaData
28
    {
29 1
        return new self($manager);
30
    }
31
32
    public function justEntitiesMetadata() : array
33
    {
34 1
        return array_map(function ($item) {
35 1
            return $item->rootEntityName;
36 1
        }, $this->metadata);
37
    }
38
39 1
    public function extractFields($entityClass) : array
40
    {
41 1
        $this->currentMetadata = $this->manager->getClassMetadata($entityClass);
42
43 1
        return array_map(function ($item) {
44 1
            return Dictionary::getOperatorsFromDoctrineType($item['type']);
45 1
        }, $this->currentMetadata->fieldMappings);
0 ignored issues
show
Bug introduced by
Accessing fieldMappings on the interface Doctrine\Common\Persistence\Mapping\ClassMetadata suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
46
    }
47
48 1
    public function haveRelations() : bool
49
    {
50
        return isset(
51 1
            $this->currentMetadata->associationMappings['members']
52
        );
53
    }
54
55 1
    public function getCurrentTargetEntity() : string
56
    {
57 1
        return $this->currentMetadata->associationMappings
58 1
            ['members']
59 1
            ['targetEntity'];
60
    }
61
}
62