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
Pull Request — master (#217)
by Eric
65:19 queued 62:20
created

AbstractHelperBuilder   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 117
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 13
lcom 1
cbo 1
dl 0
loc 117
ccs 33
cts 33
cp 1
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
A hasSubscribers() 0 4 1
A getSubscribers() 0 4 1
A setSubscribers() 0 7 1
A addSubscribers() 0 8 2
A hasSubscriber() 0 4 1
A addSubscriber() 0 8 2
A removeSubscriber() 0 7 1
A createEventDispatcher() 0 10 2
A createSubscribers() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Ivory Google Map package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\GoogleMap\Helper\Builder;
13
14
use Symfony\Component\EventDispatcher\EventDispatcher;
15
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
16
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
17
18
/**
19
 * @author GeLo <[email protected]>
20
 */
21
abstract class AbstractHelperBuilder
22
{
23
    /**
24
     * @var EventSubscriberInterface[]
25
     */
26
    private $subscribers = [];
27
28
    /**
29
     * @return static
30
     */
31
    public static function create()
32
    {
33
        return new static();
34
    }
35
36
    /**
37
     * @return bool
38
     */
39
    public function hasSubscribers()
40
    {
41
        return !empty($this->subscribers);
42
    }
43
44 332
    /**
45
     * @return EventSubscriberInterface[]
46 332
     */
47 332
    public function getSubscribers()
48 332
    {
49
        return $this->subscribers;
50
    }
51
52
    /**
53 300
     * @param EventSubscriberInterface[] $subscribers
54
     *
55 300
     * @return $this
56
     */
57
    public function setSubscribers(array $subscribers)
58
    {
59
        $this->subscribers = [];
60
        $this->addSubscribers($subscribers);
61 288
62
        return $this;
63 288
    }
64
65
    /**
66
     * @param EventSubscriberInterface[] $subscribers
67
     *
68
     * @return $this
69
     */
70
    public function addSubscribers(array $subscribers)
71 332
    {
72
        foreach ($subscribers as $subscriber) {
73 332
            $this->addSubscriber($subscriber);
74
        }
75 332
76 2
        return $this;
77
    }
78
79
    /**
80
     * @param EventSubscriberInterface $subscriber
81 288
     *
82
     * @return bool
83 288
     */
84
    public function hasSubscriber(EventSubscriberInterface $subscriber)
85
    {
86
        return in_array($subscriber, $this->subscribers, true);
87
    }
88
89
    /**
90
     * @param EventSubscriberInterface $subscriber
91 332
     *
92
     * @return $this
93 332
     */
94
    public function addSubscriber(EventSubscriberInterface $subscriber)
95 332
    {
96
        if (!$this->hasSubscriber($subscriber)) {
97
            $this->subscribers[] = $subscriber;
98
        }
99
100
        return $this;
101 24
    }
102
103 24
    /**
104 2
     * @param EventSubscriberInterface $subscriber
105
     *
106
     * @return $this
107
     */
108
    public function removeSubscriber(EventSubscriberInterface $subscriber)
109 26
    {
110 2
        unset($this->subscribers[array_search($subscriber, $this->subscribers, true)]);
111 26
        $this->subscribers = array_values($this->subscribers);
112 2
113
        return $this;
114
    }
115
116
    /**
117
     * @return EventDispatcherInterface
118
     */
119 8
    protected function createEventDispatcher()
120
    {
121 8
        $eventDispatcher = new EventDispatcher();
122 8
123
        foreach ($this->createSubscribers() as $subscriber) {
124 8
            $eventDispatcher->addSubscriber($subscriber);
125 2
        }
126
127
        return $eventDispatcher;
128
    }
129
130
    /**
131
     * @return EventSubscriberInterface[]
132 10
     */
133
    protected function createSubscribers()
134 8
    {
135 8
        return $this->subscribers;
136 6
    }
137
}
138