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

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 31
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A checkExpectations() 0 5 2
A validate() 0 5 1
A __construct() 0 4 1
A checkReservedKeys() 0 6 2
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