Total Complexity | 7 |
Total Lines | 29 |
Duplicated Lines | 0 % |
Coverage | 93.33% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | class ObserverStore |
||
6 | { |
||
7 | |||
8 | private $observers = []; |
||
9 | |||
10 | 796 | public function attach($notifier, $observer): void |
|
16 | 796 | } |
|
17 | |||
18 | 1 | public function detach($notifier, $observer): void |
|
19 | { |
||
20 | 1 | if (array_key_exists($notifier, $this->observers)) { |
|
21 | 1 | if (($key = array_search($observer, $this->observers[$notifier])) !== false) { |
|
22 | 1 | unset($this->observers[$notifier][$key]); |
|
23 | 1 | $this->observers[$notifier] = array_values($this->observers[$notifier]); |
|
24 | } |
||
25 | } |
||
26 | 1 | } |
|
27 | |||
28 | 154 | public function forNotifier($notifier): array |
|
34 | } |
||
35 | } |