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   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getSynchronizers() 0 10 2
A synchronizeCreate() 0 6 2
A synchronizeUpdate() 0 6 2
A synchronizeDelete() 0 6 2
A registerSynchronizer() 0 4 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