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