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.
Passed
Push — master ( b3cd52...71bd8a )
by Anton
02:19
created

RunCommand::execute()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
nc 6
nop 2
dl 0
loc 23
ccs 0
cts 18
cp 0
crap 20
rs 9.552
c 0
b 0
f 0
1
<?php
2
/* (c) Anton Medvedev <[email protected]>
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace Deployer\Console;
9
10
use Deployer\Deployer;
11
use Deployer\Exception\Exception;
12
use Deployer\Task\Context;
13
use Deployer\Task\Task;
14
use Symfony\Component\Console\Command\Command;
15
use Symfony\Component\Console\Input\InputArgument;
16
use Symfony\Component\Console\Input\InputInterface as Input;
17
use Symfony\Component\Console\Input\InputOption as Option;
18
use Symfony\Component\Console\Output\OutputInterface as Output;
19
use function Deployer\run;
20
use function Deployer\write;
21
use function Deployer\writeln;
22
23
class RunCommand extends SelectCommand
24
{
25
    public function __construct(Deployer $deployer)
26
    {
27
        parent::__construct('run', $deployer);
28
        $this->setDescription('Run any arbitrary command on hosts');
29
    }
30
31
    protected function configure()
32
    {
33
        parent::configure();
34
        $this->addArgument(
35
            'command-to-run',
36
            InputArgument::IS_ARRAY,
37
            'Command to run'
38
        );
39
    }
40
41
    protected function execute(Input $input, Output $output)
42
    {
43
        if ($output->getVerbosity() === Output::VERBOSITY_NORMAL) {
44
            $output->setVerbosity(Output::VERBOSITY_VERBOSE);
45
        }
46
47
        $command = implode(' ', $input->getArgument('command-to-run') ?? '');
48
        $hosts = $this->selectHosts($input, $output);
49
50
        $task = new Task($command, function () use ($command, $hosts) {
51
            run($command);
52
        });
53
54
        foreach ($hosts as $host) {
55
            try {
56
                $task->run(new Context($host, $input, $output));
57
            } catch (\Throwable $exception) {
58
                $this->deployer->messenger->renderException($exception, $host);
59
            }
60
        }
61
62
        return 0;
63
    }
64
}
65