| Conditions | 2 |
| Paths | 2 |
| Total Lines | 11 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | 11 | public function getValue($path) |
|
| 22 | { |
||
| 23 | 11 | list($section, $group, $element) = explode('/', $path); |
|
| 24 | 11 | $xpath = sprintf('/*/%s/%s/%s', $section, $group, $element); |
|
| 25 | 11 | $element = $this->xpath($xpath); |
|
| 26 | 11 | if (empty($element)) { |
|
| 27 | 3 | return null; |
|
| 28 | } |
||
| 29 | 10 | $value = (string)$element[0]; |
|
| 30 | 10 | return $value; |
|
| 31 | } |
||
| 32 | |||
| 45 |
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.