1 | <?php |
||
24 | final class ReviewChangeListener |
||
25 | { |
||
26 | /** |
||
27 | * @var ReviewableRatingUpdaterInterface |
||
28 | */ |
||
29 | private $averageRatingUpdater; |
||
30 | |||
31 | /** |
||
32 | * @param ReviewableRatingUpdaterInterface $averageRatingUpdater |
||
33 | */ |
||
34 | public function __construct(ReviewableRatingUpdaterInterface $averageRatingUpdater) |
||
38 | |||
39 | /** |
||
40 | * @param LifecycleEventArgs $args |
||
41 | */ |
||
42 | public function postPersist(LifecycleEventArgs $args) |
||
46 | |||
47 | /** |
||
48 | * @param LifecycleEventArgs $args |
||
49 | */ |
||
50 | public function postUpdate(LifecycleEventArgs $args) |
||
54 | |||
55 | /** |
||
56 | * @param LifecycleEventArgs $args |
||
57 | */ |
||
58 | public function postRemove(LifecycleEventArgs $args) |
||
59 | { |
||
60 | $this->recalculateSubjectRating($args); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @param LifecycleEventArgs $args |
||
65 | */ |
||
66 | public function recalculateSubjectRating(LifecycleEventArgs $args): void |
||
76 | } |
||
77 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: