Shell::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 7
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chinstrap\Core\Console\Commands;
6
7
use Psr\Container\ContainerInterface;
8
use Psy\Shell as Psysh;
9
use Symfony\Component\Console\Command\Command;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
final class Shell extends Command
14
{
15
    protected ContainerInterface $container;
16
17
    protected Psysh $shell;
18
19
    public function __construct(ContainerInterface $container, Psysh $shell)
20
    {
21
        parent::__construct();
22
        $this->container = $container;
23
        $this->shell = $shell;
24
    }
25
26
    protected function configure(): void
27
    {
28
        $this->setName('shell')
29
                ->setDescription('Runs an interactive shell')
30
                ->setHelp('This command runs an interactive shell');
31
    }
32
33
    protected function execute(InputInterface $input, OutputInterface $output): int
34
    {
35
        $this->shell->setScopeVariables([
36
                                         'container' => $this->container,
37
                                        ]);
38
        $this->shell->run();
39
        return 1;
40
    }
41
}
42