Passed
Pull Request — master (#91)
by Rustam
02:42
created

ClearCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A configure() 0 5 1
A execute() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Command;
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\Debug\Storage\StorageInterface;
12
13
class ClearCommand extends Command
14
{
15
    private StorageInterface $storage;
16
17
    protected static $defaultName = 'debug/reset';
18
19
    public function __construct(StorageInterface $storage)
20
    {
21
        $this->storage = $storage;
22
        parent::__construct();
23
    }
24
25
    protected function configure(): void
26
    {
27
        $this
28
            ->setDescription('Clear debug data')
29
            ->setHelp('This command clears debug storage data');
30
    }
31
32
    protected function execute(InputInterface $input, OutputInterface $output): int
33
    {
34
        $this->storage->clear();
35
36
        return ExitCode::OK;
37
    }
38
}
39