InstallCommand::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the dotfiles project.
7
 *
8
 *     (c) Anthonius Munthi <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Dotfiles\Plugins\PHPBrew\Command;
15
16
use Dotfiles\Core\Command\CommandInterface;
17
use Dotfiles\Core\Processor\Patcher;
18
use Dotfiles\Plugins\PHPBrew\Installer;
19
use Symfony\Component\Console\Command\Command;
20
use Symfony\Component\Console\Input\InputInterface;
21
use Symfony\Component\Console\Input\InputOption;
22
use Symfony\Component\Console\Output\OutputInterface;
23
24
class InstallCommand extends Command implements CommandInterface
25
{
26
    /**
27
     * @var Installer
28
     */
29
    private $installer;
30
31
    /**
32
     * @var Patcher
33
     */
34
    private $patcher;
35
36
    public function __construct(?string $name = null, Installer $installer, Patcher $patcher)
37
    {
38
        parent::__construct($name);
39
        $this->installer = $installer;
40
        $this->patcher = $patcher;
41
    }
42
43
    public function configure(): void
44
    {
45
        $this
46
            ->setName('phpbrew:install')
47
            ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force install phpbrew')
48
        ;
49
    }
50
51
    public function execute(InputInterface $input, OutputInterface $output): void
52
    {
53
        $this->installer->run($input->getOption('force'));
54
        $this->patcher->run();
55
    }
56
}
57