Passed
Pull Request — master (#80)
by
unknown
02:03
created

SchemaRebuildCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 13
c 1
b 0
f 0
dl 0
loc 28
ccs 0
cts 11
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 4 1
A execute() 0 7 1
A __construct() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Cycle\Command\Common;
6
7
use Psr\Container\ContainerInterface;
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Input\InputArgument;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
use Yiisoft\Yii\Console\ExitCode;
13
use Yiisoft\Yii\Cycle\Command\CycleDependencyProxy;
14
use Yiisoft\Yii\Cycle\Command\Common\SchemaPhpCommand;
15
16
class SchemaRebuildCommand extends Command
17
{
18
    protected static $defaultName = 'cycle/schema/rebuild';
19
20
    private CycleDependencyProxy $promise;
21
22
    private ?ContainerInterface $container = null;
23
24
    public function __construct(CycleDependencyProxy $promise, ContainerInterface $container)
25
    {
26
        $this->promise = $promise;
27
        $this->container = $container;
28
        parent::__construct();
29
    }
30
31
    public function configure(): void
32
    {
33
        $this->setDescription('Rebuild schema')
34
            ->addArgument('file', InputArgument::OPTIONAL, 'file');
35
    }
36
37
    protected function execute(InputInterface $input, OutputInterface $output): int
38
    {
39
        $this->promise->getSchemaProvider()->clear();
40
        $schemaPhpCommand = $this->container->get(SchemaPhpCommand::class);
0 ignored issues
show
Bug introduced by
The method get() does not exist on null. ( Ignorable by Annotation )

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

40
        /** @scrutinizer ignore-call */ 
41
        $schemaPhpCommand = $this->container->get(SchemaPhpCommand::class);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
        $schemaPhpCommand->execute($input, $output);
42
43
        return ExitCode::OK;
44
    }
45
}
46