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.

Worker::execute()   A
last analyzed

Complexity

Conditions 5
Paths 17

Size

Total Lines 21
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 5.0144

Importance

Changes 0
Metric Value
cc 5
eloc 14
nc 17
nop 2
dl 0
loc 21
rs 9.4888
c 0
b 0
f 0
ccs 11
cts 12
cp 0.9167
crap 5.0144
1
<?php
2
3
declare(strict_types=1);
4
5
/* (c) Anton Medvedev <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Deployer\Executor;
12
13
use Deployer\Deployer;
14
use Deployer\Exception\Exception;
15
use Deployer\Exception\GracefulShutdownException;
16
use Deployer\Exception\RunException;
17
use Deployer\Host\Host;
18
use Deployer\Task\Context;
19
use Deployer\Task\Task;
20
use Throwable;
21
22
class Worker
23 8
{
24
    private Deployer $deployer;
25 8
26 8
    public function __construct(Deployer $deployer)
27
    {
28 8
        $this->deployer = $deployer;
29
    }
30
31 8
    public function execute(Task $task, Host $host): int
32
    {
33 8
        try {
34
            Exception::setTaskSourceLocation($task->getSourceLocation());
35 8
36 8
            $context = new Context($host);
37
            $task->run($context);
38 8
39 2
            if ($task->getName() !== 'connect') {
40 2
                $this->deployer->messenger->endOnHost($host);
41 2
            }
42 1
            return 0;
43
        } catch (Throwable $e) {
44 1
            $this->deployer->messenger->renderException($e, $host);
45 1
            if ($e instanceof GracefulShutdownException) {
46
                return GracefulShutdownException::EXIT_CODE;
47
            }
48
            if ($e instanceof RunException) {
49
                return $e->getExitCode();
50
            }
51
            return 255;
52
        }
53
    }
54
}
55