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.

JobRunner   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 39
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 20 5
1
<?php
2
3
namespace Scheduler\JobRunner;
4
5
use Scheduler\ActionInspector\ActionInspectorInterface;
6
use Scheduler\SchedulerInterface;
7
use DateTimeInterface;
8
use Scheduler\Action\Report;
9
10
/**
11
 * Class JobRunner
12
 * @package Scheduler\JobRunner
13
 * @author Aleh Hutnikau, <[email protected]>
14
 */
15
class JobRunner implements JobRunnerInterface
16
{
17
18
    /** @var ActionInspectorInterface */
19
    protected $actionLog;
20
21
    /**
22
     * JobRunner constructor.
23
     * @param ActionInspectorInterface|null $actionLog
24
     */
25 4
    public function __construct(ActionInspectorInterface $actionLog = null)
26
    {
27 4
        $this->actionLog = $actionLog;
28 4
    }
29
30
    /**
31
     * @inheritdoc
32
     */
33 2
    public function run(SchedulerInterface $scheduler, DateTimeInterface $from, DateTimeInterface $to = null, $inc = true)
34
    {
35 2
        $actionsIterator = $scheduler->getIterator($from, $to, $inc);
36 2
        $reports = [];
37 2
        foreach ($actionsIterator as $action) {
38
            try {
39 2
                if ($this->actionLog === null) {
40 2
                    $reports[] = new Report($action, $action());
41 2
                } else if ($this->actionLog->update($action)) {
42 1
                    $reports[] = new Report($action, $action());
43 1
                    $this->actionLog->update($action);
44 1
                } else {
45
                    //action already executed or taken by another worker
46
                }
47 2
            } catch (\Exception $e) {
48 1
                $reports[] = new Report($action, $e, Report::TYPE_ERROR);
49
            }
50 2
        }
51 2
        return $reports;
52
    }
53
}