Passed
Pull Request — master (#97)
by Mlax
17:06 queued 02:05
created

RebuildCommand::io()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 3
c 1
b 0
f 1
dl 0
loc 6
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Composer\Config\Command;
6
7
use Symfony\Component\Console\Input\ArgvInput;
8
use Symfony\Component\Console\Output\ConsoleOutput;
9
use Symfony\Component\Console\Command\Command;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Input\InputOption;
12
use Symfony\Component\Console\Output\OutputInterface;
13
use Symfony\Component\Console\Style\SymfonyStyle;
14
use Yiisoft\Composer\Config\Builder;
15
16
final class RebuildCommand extends Command
17
{
18
    private ?SymfonyStyle $io = null;
19
20
    protected static $defaultName = 'config/rebuild';
21
22
    public function __construct()
23
    {
24
        parent::__construct();
25
    }
26
27
    public function configure(): void
28
    {
29
        $this
30
            ->setDescription('Rebuild Yii configuration.')
31
            ->addOption('baseDir', null, InputOption::VALUE_OPTIONAL, 'Base directory', null)
32
            ->setHelp('This command rebuild Yii configuration..');
33
    }
34
35
    protected function execute(InputInterface $input, OutputInterface $output): int
36
    {
37
        $baseDir = $input->getOption('baseDir');
38
        Builder::rebuild($baseDir);
39
        $this->io()->success('Rebuild Yii configuration successfully.');
40
        return ExitCode::OK;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Composer\Config\Command\ExitCode was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
41
    }
42
43
    private function io(): SymfonyStyle
44
    {
45
        if ($this->io === null) {
46
            $this->io = new SymfonyStyle(new ArgvInput(), new ConsoleOutput());
47
        }
48
        return $this->io;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->io could return the type null which is incompatible with the type-hinted return Symfony\Component\Console\Style\SymfonyStyle. Consider adding an additional type-check to rule them out.
Loading history...
49
    }
50
}
51