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.

SynchronizerManager::getSynchronizers()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
namespace Nimble\ElasticBundle\Synchronizer;
4
5
use Nimble\ElasticBundle\ClassUtils;
6
7
class SynchronizerManager
8
{
9
    /**
10
     * @var array
11
     */
12
    protected $synchronizers = [];
13
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function registerSynchronizer(SynchronizerInterface $synchronizer)
18
    {
19
        $this->synchronizers[$synchronizer->getClassName()][] = $synchronizer;
20
    }
21
22
    /**
23
     * @param object $entity
24
     * @return SynchronizerInterface[]
25
     */
26
    protected function getSynchronizers($entity)
27
    {
28
        $classKey = ClassUtils::findClassKey(get_class($entity), $this->synchronizers);
29
30
        if (!$classKey) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $classKey of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
31
            return [];
32
        }
33
34
        return $this->synchronizers[$classKey];
35
    }
36
37
    /**
38
     * @param object $entity
39
     */
40
    public function synchronizeCreate($entity)
41
    {
42
        foreach ($this->getSynchronizers($entity) as $synchronizer) {
43
            $synchronizer->synchronizeCreate($entity);
44
        }
45
    }
46
47
    /**
48
     * @param object $entity
49
     */
50
    public function synchronizeUpdate($entity)
51
    {
52
        foreach ($this->getSynchronizers($entity) as $synchronizer) {
53
            $synchronizer->synchronizeUpdate($entity);
54
        }
55
    }
56
57
    /**
58
     * @param object $entity
59
     */
60
    public function synchronizeDelete($entity)
61
    {
62
        foreach ($this->getSynchronizers($entity) as $synchronizer) {
63
            $synchronizer->synchronizeDelete($entity);
64
        }
65
    }
66
}
67