Total Complexity | 5 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | final class ReactionObserver |
||
22 | { |
||
23 | private $eventDispatcher; |
||
24 | |||
25 | public function __construct( |
||
26 | DispatcherContract $eventDispatcher |
||
27 | ) { |
||
28 | $this->eventDispatcher = $eventDispatcher; |
||
29 | } |
||
30 | |||
31 | public function creating( |
||
32 | Reaction $reaction |
||
33 | ): void { |
||
34 | if ($reaction->getAttributeValue('rate') === null) { |
||
35 | $reaction->setAttribute('rate', Reaction::RATE_DEFAULT); |
||
36 | } |
||
37 | } |
||
38 | |||
39 | public function created( |
||
40 | Reaction $reaction |
||
41 | ): void { |
||
42 | $this->eventDispatcher->dispatch( |
||
43 | new ReactionHasBeenAdded($reaction) |
||
44 | ); |
||
45 | } |
||
46 | |||
47 | public function deleted( |
||
52 | ); |
||
53 | } |
||
54 | } |
||
55 |