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.

BaseObject::__get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 8
loc 8
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace SimaLand\API;
4
5
use Monolog\Handler\StreamHandler;
6
use Monolog\Logger;
7
use Psr\Log\LoggerInterface;
8
9
/**
10
 * Базовый класс.
11
 */
12
class BaseObject
13
{
14
    /**
15
     * Наименование лога.
16
     */
17
    const LOGGER_NAME = 'SimaAPI';
18
19
    /**
20
     * @var \Psr\Log\LoggerInterface
21
     */
22
    private $logger;
23
24
    /**
25
     * @param array $options
26
     */
27 123
    public function __construct(array $options = [])
28
    {
29 123
        foreach ($options as $key => $value) {
30 120
            $this->{$key} = $value;
31 41
        }
32 123
    }
33
34
    /**
35
     * Получить логгер.
36
     *
37
     * @return \Psr\Log\LoggerInterface
38
     */
39 69
    public function getLogger()
40
    {
41 69
        if (is_null($this->logger)) {
42 3
            $this->logger = new Logger(self::LOGGER_NAME);
43 3
            $this->logger->pushHandler(new StreamHandler('php://output'));
44 1
        }
45 69
        return $this->logger;
46
    }
47
48
    /**
49
     * Установить логгер.
50
     *
51
     * @param \Psr\Log\LoggerInterface $logger
52
     * @return $this
53
     */
54 3
    public function setLogger(LoggerInterface $logger)
55
    {
56 3
        $this->logger = $logger;
57 3
        return $this;
58
    }
59
60
    /**
61
     * @param string $key
62
     * @param mixed $value
63
     */
64 24 View Code Duplication
    public function __set($key, $value)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
65
    {
66 24
        $setter = 'set' . ucfirst($key);
67 24
        if (method_exists($this, $setter)) {
68 24
            call_user_func([$this, $setter], $value);
69 24
            return;
70
        }
71 3
        $this->{$key} = $value;
72 3
    }
73
74
    /**
75
     * @param string $key
76
     * @return mixed
77
     */
78 21 View Code Duplication
    public function __get($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
79
    {
80 21
        $getter = 'get' . ucfirst($key);
81 21
        if (method_exists($this, $getter)) {
82 21
            return call_user_func([$this, $getter]);
83
        }
84 3
        return $this->{$key};
85
    }
86
}
87