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::run()   A
last analyzed

Complexity

Conditions 5
Paths 8

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 20
ccs 14
cts 14
cp 1
rs 9.2888
c 0
b 0
f 0
cc 5
nc 8
nop 4
crap 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
}