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.
Completed
Push — master ( 12c034...1ec743 )
by
unknown
12s
created

Json::open()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 0
crap 2
1
<?php
2
3
namespace SimaLand\API\Parser;
4
5
use SimaLand\API\Object;
6
use SimaLand\API\Record;
7
8
/**
9
 * Сохранение данных в json файл.
10
 */
11
class Json extends Object 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 12
        }
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 12
        }
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