InstallCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 30
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 5 1
A __construct() 0 4 1
A execute() 0 3 1
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\Composer\Command;
15
16
use Dotfiles\Core\Command\Command;
17
use Dotfiles\Plugins\Composer\Installer;
18
use Symfony\Component\Console\Input\InputInterface;
19
use Symfony\Component\Console\Input\InputOption;
20
use Symfony\Component\Console\Output\OutputInterface;
21
22
class InstallCommand extends Command
23
{
24
    /**
25
     * @var Installer
26
     */
27
    private $installer;
28
29
    /**
30
     * InstallCommand constructor.
31
     *
32
     * @param null|string $name
33
     * @param Installer   $installer
34
     */
35
    public function __construct(?string $name = null, Installer $installer)
36
    {
37
        parent::__construct($name);
38
        $this->installer = $installer;
39
    }
40
41
    protected function configure(): void
42
    {
43
        $this
44
            ->setName('composer:install')
45
            ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force install composer even when already installed')
46
        ;
47
    }
48
49
    protected function execute(InputInterface $input, OutputInterface $output): void
50
    {
51
        $this->installer->run($input->getOption('force'));
52
    }
53
}
54