| Conditions | 5 |
| Paths | 5 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | public function parseToJson($url) |
||
| 23 | { |
||
| 24 | $this->loadContent($url); |
||
| 25 | $configurations = $this->parser->find('ul#blocsplans li'); |
||
| 26 | if (0 >= $configurations->count()) { |
||
| 27 | throw new \Exception(sprintf('Configuration not found for this url: %s', $url)); |
||
| 28 | } |
||
| 29 | |||
| 30 | $configurationList = []; |
||
| 31 | foreach ($configurations as $conf) { |
||
|
|
|||
| 32 | foreach ($conf->find('p a') as $link) { |
||
| 33 | if (null !== $configurationFor = $this->urlTransformer->reverseConfiguration($link->href)) |
||
| 34 | $configurationList[] = $configurationFor; |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | return json_encode($configurationList, true); |
||
| 39 | } |
||
| 40 | |||
| 48 | } |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.