1 | <?php |
||
2 | |||
3 | namespace Bavix\SDK\FileLoader; |
||
4 | |||
5 | use Symfony\Component\Yaml\Yaml; |
||
6 | |||
7 | class YamlLoader 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 | $yml = \file_get_contents($this->path); |
|
20 | 1 | $this->data = Yaml::parse($yml); |
|
21 | } |
||
22 | |||
23 | 1 | return $this->data; |
|
24 | } |
||
25 | |||
26 | /** |
||
27 | * @inheritdoc |
||
28 | */ |
||
29 | public function save($data) |
||
30 | { |
||
31 | $data = $this->_fromArray($data); |
||
32 | |||
33 | return (bool)\file_put_contents( |
||
34 | $this->path, |
||
35 | Yaml::dump($data) |
||
36 | ); |
||
37 | } |
||
38 | |||
39 | } |
||
40 |
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.