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.

PreProcessor::validate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace crojasaragonez\LightService;
6
7
class PreProcessor
8
{
9
    private $organizer;
10
    private $action;
11 15
    public function __construct(Organizer $organizer, Action $action)
12
    {
13 15
        $this->organizer = $organizer;
14 15
        $this->action    = $action;
15 15
    }
16
17 15
    public static function validate(Organizer $organizer, Action $action)
18
    {
19 15
        $instance = new self($organizer, $action);
20 15
        $instance->checkExpectations();
21 12
        $instance->checkReservedKeys();
22 9
    }
23
24 15
    private function checkExpectations()
25
    {
26 15
        $missing_keys = ContextHelper::missingKeys($this->action->expects, $this->organizer->context);
27 15
        if ($missing_keys) {
28 3
            throw new \Exception("expected '$missing_keys' to be in the context during " . get_class($this->action));
29
        }
30 12
    }
31
32 12
    private function checkReservedKeys()
33
    {
34 12
        $action_keys = array_merge($this->action->expects, $this->action->promises);
35 12
        $reserved_keys_in_use = ContextHelper::forbiddenKeys(Organizer::RESERVED_KEYS, $action_keys);
36 12
        if ($reserved_keys_in_use) {
37 3
            throw new \Exception("promised or expected keys cannot be a reserved key ('$reserved_keys_in_use')");
38
        }
39 9
    }
40
}
41