Completed
Push — master ( 4e9ef9...340c5c )
by Craig
10:22 queued 05:05
created

ZikulaExtensionInstallCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 16 3
A configure() 0 6 1
1
<?php
2
3
namespace Zikula\ExtensionsModule\Command;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Symfony\Component\Console\Style\SymfonyStyle;
11
12
class ZikulaExtensionInstallCommand extends Command
13
{
14
    protected static $defaultName = 'zikula:extension:install';
15
16
    protected function configure()
17
    {
18
        $this
19
            ->setDescription('Install a zikula module or theme.')
20
            ->addArgument('arg1', InputArgument::OPTIONAL, 'Argument description')
21
            ->addOption('option1', null, InputOption::VALUE_NONE, 'Option description')
22
        ;
23
    }
24
25
    protected function execute(InputInterface $input, OutputInterface $output): int
26
    {
27
        $io = new SymfonyStyle($input, $output);
28
        $arg1 = $input->getArgument('arg1');
29
30
        if ($arg1) {
31
            $io->note(sprintf('You passed an argument: %s', $arg1));
0 ignored issues
show
Bug introduced by
It seems like $arg1 can also be of type string[]; however, parameter $args of sprintf() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

31
            $io->note(sprintf('You passed an argument: %s', /** @scrutinizer ignore-type */ $arg1));
Loading history...
32
        }
33
34
        if ($input->getOption('option1')) {
35
            // ...
36
        }
37
38
        $io->success('You have a new command! Now make it your own! Pass --help to see your options.');
39
40
        return 0;
41
    }
42
}
43