Total Complexity | 8 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class Subject |
||
10 | { |
||
11 | protected $observers = []; |
||
12 | protected $name; |
||
13 | |||
14 | public function __construct($name) |
||
17 | } |
||
18 | |||
19 | public function getName() |
||
22 | } |
||
23 | |||
24 | public function attach(Observer $observer) |
||
25 | { |
||
26 | $this->observers[] = $observer; |
||
27 | } |
||
28 | |||
29 | public function doSomething() |
||
36 | } |
||
37 | |||
38 | public function doSomethingBad() |
||
39 | { |
||
40 | foreach ($this->observers as $observer) { |
||
41 | $observer->reportError(42, 'Something bad happened', $this); |
||
42 | } |
||
43 | } |
||
44 | |||
45 | protected function notify($argument) |
||
49 | } |
||
50 | } |
||
51 | } |
||
52 |