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.

ActionRegistry   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 4
dl 0
loc 70
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
B act() 0 23 6
A setDebug() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Netgen\InformationCollection\Core\Action;
6
7
use function in_array;
8
use Netgen\InformationCollection\API\Action\ActionInterface;
9
use Netgen\InformationCollection\API\Action\CrucialActionInterface;
10
use Netgen\InformationCollection\API\Exception\ActionFailedException;
11
use Netgen\InformationCollection\API\Value\Event\InformationCollected;
12
use Psr\Log\LoggerInterface;
13
use function get_class;
14
15
final class ActionRegistry implements ActionInterface
16
{
17
    /**
18
     * @var array
19
     */
20
    private $actions;
21
22
    /**
23
     * @var \Psr\Log\LoggerInterface
24
     */
25
    private $logger;
26
27
    /**
28
     * @var bool
29
     */
30
    private $debug = false;
31
32
    /**
33
     * @var \Netgen\InformationCollection\Core\Action\ConfigurationUtility
34
     */
35
    private $utility;
36
37
    /**
38
     * ActionAggregate constructor.
39
     *
40
     * @param array $actions
41
     * @param \Netgen\InformationCollection\Core\Action\ConfigurationUtility $utility
42
     * @param \Psr\Log\LoggerInterface $logger
43
     */
44
    public function __construct(iterable $actions, ConfigurationUtility $utility, LoggerInterface $logger)
45
    {
46
        $this->actions = $actions;
47
        $this->logger = $logger;
48
        $this->utility = $utility;
49
    }
50
51
    public function act(InformationCollected $event): void
52
    {
53
        $config = $this->utility->getConfigPerContentType($event->getContentType());
54
55
        foreach ($this->actions as $action) {
56
            if ($this->utility->isActionAllowedToRun($action, $config)) {
57
                try {
58
                    $action->act($event);
59
                } catch (ActionFailedException $e) {
60
                    $this->logger
61
                        ->error($e->getMessage());
62
63
                    if ($this->debug) {
64
                        throw $e;
65
                    }
66
67
                    if ($action instanceof CrucialActionInterface) {
68
                        break;
69
                    }
70
                }
71
            }
72
        }
73
    }
74
75
    /**
76
     * Sets debug variable based on kernel.debug param.
77
     *
78
     * @param bool $debug
79
     */
80
    public function setDebug($debug)
81
    {
82
        $this->debug = $debug;
83
    }
84
}
85