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   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 46
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A log() 0 9 3
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