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.
Completed
Push — master ( c622f2...85cf53 )
by Anderson
02:20
created

ElasticRepositoryManager   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getRepository() 0 20 4
A getAnnotationReader() 0 7 2
1
<?php
2
3
namespace DoctrineElastic\Repository;
4
5
use Doctrine\Common\Annotations\AnnotationReader;
6
use Doctrine\ORM\Mapping\Entity;
7
use DoctrineElastic\ElasticEntityManager;
8
9
/**
10
 * @author Andsalves <[email protected]>
11
 */
12
class ElasticRepositoryManager {
13
14
    /** @var ElasticEntityRepository[] */
15
    protected $repositoryList;
16
17
    /** @var AnnotationReader */
18
    protected $annotationReader;
19
20
    public function getRepository(ElasticEntityManager $entityManager, $className) {
21
        $hashKey = md5($className) . spl_object_hash($entityManager);
22
23
        if (!isset($this->repositoryList[$hashKey])) {
24
            $repositoryClass = ElasticEntityRepository::class;
25
26
            /** @var Entity $entityAnnotation */
27
            $entityAnnotation = $this->getAnnotationReader()->getClassAnnotation(
28
                new \ReflectionClass($className), Entity::class
29
            );
30
            if (!is_null($entityAnnotation) && isset($entityAnnotation->repositoryClass)) {
31
                $repositoryClass = $entityAnnotation->repositoryClass;
32
            }
33
34
            $repository = new $repositoryClass($entityManager, $className);
35
            $this->repositoryList[$hashKey] = $repository;
36
        }
37
38
        return $this->repositoryList[$hashKey];
39
    }
40
41
    public function getAnnotationReader() {
42
        if (is_null($this->annotationReader)) {
43
            $this->annotationReader = new AnnotationReader();
44
        }
45
46
        return $this->annotationReader;
47
    }
48
}
49