| Conditions | 5 |
| Paths | 6 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 41 | public function config(string $key, $default = null) |
||
| 42 | { |
||
| 43 | if (!$this->config) { |
||
|
|
|||
| 44 | $this->config = (new Path)->readAsJson($this->workDir . '/composer.json'); |
||
| 45 | } |
||
| 46 | |||
| 47 | $temp = $this->config; |
||
| 48 | foreach (\explode('.', $key) as $part) { |
||
| 49 | if (\is_array($temp) && \array_key_exists($part, $temp)) { |
||
| 50 | $temp = $temp[$part]; |
||
| 51 | } else { |
||
| 52 | return $default; |
||
| 53 | } |
||
| 54 | } |
||
| 55 | |||
| 56 | return $temp; |
||
| 57 | } |
||
| 59 |
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.