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::save()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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