Passed
Push — master ( 5b634b...5acd4d )
by Бабичев
05:11
created

src/SDK/FileLoader/IniLoader.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Bavix\SDK\FileLoader;
4
5
class IniLoader implements DataInterface
6
{
7
8
    use DataTrait;
9
10
    /**
11
     * @var IniWriter
12
     */
13
    protected $writer;
14
15
    /**
16
     * @return IniWriter
17
     */
18
    protected function writer()
19
    {
20
        if (!$this->writer)
21
        {
22
            $this->writer = new IniWriter();
23
        }
24
25
        return $this->writer;
26
    }
27
28
    /**
29
     * @inheritdoc
30
     */
31
    public function asArray()
32
    {
33
        if (!$this->data)
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->data of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

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.

Loading history...
34
        {
35
            $this->data = \parse_ini_file($this->path, true);
36
        }
37
38
        return $this->data;
39
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44
    public function save($data)
45
    {
46
        $data = $this->_fromArray($data);
47
48
        return (int)$this->writer()
49
            ->toFile($this->path, $data);
50
    }
51
52
}
53