Passed
Pull Request — master (#40)
by Aleksei
13:31 queued 20s
created

SchemaClearCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 21
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 4 1
A __construct() 0 4 1
A configure() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Cycle\Command\Common;
6
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Yiisoft\Yii\Console\ExitCode;
11
use Yiisoft\Yii\Cycle\Command\CycleDependencyProxy;
12
13
class SchemaClearCommand extends Command
14
{
15
    protected static $defaultName = 'cycle/schema/clear';
16
17
    private CycleDependencyProxy $promise;
18
19
    public function __construct(CycleDependencyProxy $promise)
20
    {
21
        $this->promise = $promise;
22
        parent::__construct();
23
    }
24
25
    public function configure(): void
26
    {
27
        $this->setDescription('Clear current schema cache');
28
    }
29
30
    protected function execute(InputInterface $input, OutputInterface $output): int
31
    {
32
        $this->promise->getSchemaManager()->clear();
33
        return ExitCode::OK;
34
    }
35
}
36