| Conditions | 4 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | private function get($name, array $rawConfigs) |
||
| 33 | { |
||
| 34 | if (isset($this->index[$name])) { |
||
| 35 | return $this->index[$name]; |
||
| 36 | } |
||
| 37 | if (!array_key_exists($name, $rawConfigs)) { |
||
| 38 | throw new \InvalidArgumentException( |
||
| 39 | sprintf('no "%s" in [%s]', $name, implode(', ', array_keys($rawConfigs))) |
||
| 40 | ); |
||
| 41 | } |
||
| 42 | $rawConfig = $rawConfigs[$name]; |
||
| 43 | $parent = null; |
||
| 44 | if (isset($rawConfig['parent'])) { |
||
| 45 | $parentCollection = $this->get($rawConfig['parent'], $rawConfigs); |
||
| 46 | $parent = $parentCollection->getRepresentant(); |
||
| 47 | } |
||
| 48 | |||
| 49 | return $this->index[$name] = new Config($name, $rawConfig, $parent); |
||
| 50 | } |
||
| 51 | } |
||
| 52 |
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.