Conditions | 5 |
Paths | 5 |
Total Lines | 20 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 5 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | 3 | public function parseToJson($url) |
|
25 | { |
||
26 | 3 | $this->loadContent($url); |
|
27 | 3 | $configurations = $this->parser->find('ul#blocsplans li'); |
|
28 | 3 | if (0 >= $configurations->count()) { |
|
29 | 1 | throw new \Exception(sprintf('Configuration not found for this url: %s', $url)); |
|
30 | } |
||
31 | |||
32 | 2 | $configurationList = []; |
|
33 | 2 | foreach ($configurations as $conf) { |
|
|
|||
34 | 2 | foreach ($conf->find('p a') as $link) { |
|
35 | 2 | $configurationFor = $this->getUrlTransformer()->reverseConfiguration($link->href); |
|
36 | 1 | if (null !== $configurationFor) { |
|
37 | 1 | $configurationList[] = $configurationFor; |
|
38 | 1 | } |
|
39 | 1 | } |
|
40 | 1 | } |
|
41 | |||
42 | 1 | return json_encode($configurationList, true); |
|
43 | } |
||
44 | |||
67 |
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.