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.

AbstractConfigurableSniff   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 20
dl 0
loc 46
ccs 21
cts 21
cp 1
rs 10
c 2
b 0
f 0
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 31 6
1
<?php
2
3
namespace Gskema\TypeSniff\Sniffs;
4
5
use PHP_CodeSniffer\Files\File;
6
use PHP_CodeSniffer\Sniffs\Sniff;
7
8
abstract class AbstractConfigurableSniff implements Sniff
9
{
10
    protected bool $configured = false;
11
12
    /**
13
     * @inheritDoc
14
     */
15 16
    public function process(File $file, $ptr): void
16
    {
17
        // File path sniffs and not saved using sniff code and their config
18
        // is not processed. This is a workaround.
19 16
        if (!$this->configured) {
20 16
            $bits = explode('\\', get_class($this));
21 16
            $currentClass = end($bits);
22
23 16
            $opts = [];
24 16
            foreach ($file->ruleset->ruleset as $ref => $rule) {
25 16
                $bits = explode('/', $ref);
26 16
                $cfgClass = rtrim(end($bits), '.php');
27 16
                if ($currentClass === $cfgClass) {
28 16
                    $opts = $rule['properties'];
29 16
                    break;
30
                }
31
            }
32
33 16
            array_walk_recursive($opts, function (&$val) {
34 16
                if ('true' === $val) {
35 1
                    $val = true;
36 15
                } elseif ('false' === $val) {
37 1
                    $val = false;
38
                }
39 16
            });
40
41 16
            $this->configure($opts);
42 16
            $this->configured = true;
43
        }
44
45 16
        $this->run($file, $ptr);
46 16
    }
47
48
    /**
49
     * @param mixed[] $config
50
     */
51
    abstract protected function configure(array $config): void;
52
53
    abstract protected function run(File $file, int $ptr): void;
54
}
55