| Conditions | 4 |
| Paths | 3 |
| Total Lines | 14 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | public function setComponentLocations(GetResponseForControllerResultEvent $event): void |
||
| 31 | { |
||
| 32 | $page = $event->getControllerResult(); |
||
| 33 | $method = $event->getRequest()->getMethod(); |
||
| 34 | |||
| 35 | if (!$page instanceof AbstractDynamicPage || Request::METHOD_GET !== $method) { |
||
| 36 | return; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** @var ComponentLocationRepository $repository */ |
||
| 40 | $repository = $this->container->get(ComponentLocationRepository::class); |
||
| 41 | $locations = $repository->findByDynamicPage($page); |
||
| 42 | if ($locations) { |
||
|
|
|||
| 43 | $page->setComponentLocations($locations); |
||
| 44 | } |
||
| 47 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.