GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Json::close()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace SimaLand\API\Parser;
4
5
use SimaLand\API\Object;
6
7
/**
8
 * Сохранение данных в json файл.
9
 */
10
class Json extends Object implements StorageInterface
11
{
12
    /**
13
     * Пулный путь до файла.
14
     *
15
     * @var
16
     */
17
    public $filename;
18
19
    /**
20
     * Указатель на файл.
21
     *
22
     * @var
23
     */
24
    private $fileHandler;
25
26
    /**
27
     * Открыть файл на запись
28
     */
29
    public function open()
30
    {
31
        if (is_null($this->fileHandler)) {
32
            $this->fileHandler = fopen($this->filename, "a+");
33
        }
34
    }
35
36
    /**
37
     * Закрыть файл.
38
     */
39
    public function close()
40
    {
41
        if ($this->fileHandler) {
42
            fclose($this->fileHandler);
43
            $this->fileHandler = null;
44
        }
45
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50
    public function save(array $item)
51
    {
52
        $this->open();
53
        fputs($this->fileHandler, json_encode($item, JSON_UNESCAPED_UNICODE) . PHP_EOL);
54
    }
55
56
    /**
57
     * Уничтожить объект.
58
     */
59
    public function __destruct()
60
    {
61
        $this->close();
62
    }
63
}
64