bavix /
sdk
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Bavix\SDK\FileLoader; |
||
| 4 | |||
| 5 | use Bavix\XMLReader\XMLReader; |
||
| 6 | |||
| 7 | class XmlLoader implements DataInterface |
||
| 8 | { |
||
| 9 | |||
| 10 | use DataTrait; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @inheritdoc |
||
| 14 | */ |
||
| 15 | 1 | public function asArray() |
|
| 16 | { |
||
| 17 | 1 | if (!$this->data) |
|
|
0 ignored issues
–
show
|
|||
| 18 | { |
||
| 19 | 1 | $this->data = XMLReader::sharedInstance()->asArray($this->path); |
|
| 20 | } |
||
| 21 | |||
| 22 | 1 | return $this->data; |
|
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @inheritdoc |
||
| 27 | */ |
||
| 28 | public function save($data) |
||
| 29 | { |
||
| 30 | $data = $this->_fromArray($data); |
||
| 31 | |||
| 32 | return (bool)\file_put_contents( |
||
| 33 | $this->path, |
||
| 34 | XMLReader::sharedInstance()->asXML($data) |
||
| 35 | ); |
||
| 36 | } |
||
| 37 | |||
| 38 | } |
||
| 39 |
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.