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.

ContextFilterLogger::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 4
dl 0
loc 7
ccs 6
cts 6
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace WyriHaximus\PSR3\Filter;
4
5
use Psr\Log\AbstractLogger;
6
use Psr\Log\LoggerInterface;
7
use function igorw\get_in;
8
9
final class ContextFilterLogger extends AbstractLogger
10
{
11
    /**
12
     * @var array
13
     */
14
    private $field;
15
16
    /**
17
     * @var array
18
     */
19
    private $values;
20
21
    /**
22
     * @var LoggerInterface
23
     */
24
    private $logger;
25
26
    /**
27
     * @var bool
28
     */
29
    private $exclude;
30
31
    /**
32
     * @param string          $field
33
     * @param array           $values
34
     * @param LoggerInterface $logger
35
     * @param bool            $exclude
36
     */
37 16
    public function __construct(string $field, array $values, LoggerInterface $logger, bool $exclude = true)
38
    {
39 16
        $this->field = explode('.', $field);
40 16
        $this->values = $values;
41 16
        $this->logger = $logger;
42 16
        $this->exclude = $exclude;
43 16
    }
44
45 15
    public function log($level, $message, array $context = [])
46
    {
47 15
        $value = get_in($context, $this->field);
48 15
        if ($value !== null && in_array($value, $this->values, true) === $this->exclude) {
49 2
            return;
50
        }
51
52 15
        $this->logger->log($level, $message, $context);
53 14
    }
54
}
55