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 )
by Simone
02:59
created

CurrentMetaData::getCurrentTargetEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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)
28
    {
29 1
        return new self($manager);
30
    }
31
32
    public function lightMetaData()
33
    {
34 1
        return array_map(function ($item) {
35 1
            return $item->rootEntityName;
36 1
        }, $this->metadata);
37
    }
38
39 1
    public function extractField($entityClass)
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 haveCurrentMetadataRelations()
49
    {
50
        return isset(
51 1
            $this->currentMetadata->associationMappings['members']
52
        );
53
    }
54
55 1
    public function getCurrentTargetEntity()
56
    {
57 1
        return $this->currentMetadata->associationMappings
58 1
            ['members']
59 1
            ['targetEntity'];
60
    }
61
}
62