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   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 54
ccs 18
cts 18
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A open() 0 6 2
A close() 0 7 2
A save() 0 5 1
A __destruct() 0 4 1
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