Passed
Push — master ( 481714...398263 )
by Chema
01:30 queued 13s
created

ClearCacheCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Console\Infrastructure\Command;
6
7
use Gacela\Console\ConsoleFacade;
8
use Gacela\Framework\DocBlockResolverAwareTrait;
9
use Symfony\Component\Console\Command\Command;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
use function count;
14
15
/**
16
 * @method ConsoleFacade getFacade()
17
 */
18
final class ClearCacheCommand extends Command
19
{
20
    use DocBlockResolverAwareTrait;
21
22
    protected function configure(): void
23
    {
24
        $this->setName('clear:cache')
25
            ->setDescription('Clear all gacela cache files');
26
    }
27
28
    protected function execute(InputInterface $input, OutputInterface $output): int
29
    {
30
        $removedFilenames = $this->getFacade()->clearCacheFile();
31
32
        if (count($removedFilenames) === 0) {
33
            $output->writeln('<fg=yellow>No gacela cache files found.</>');
34
        } else {
35
            $output->writeln('<fg=green>Gacela cache files cleared successfully:</>');
36
            foreach ($removedFilenames as $filename) {
37
                $output->writeln("> {$filename}");
38
            }
39
        }
40
41
        return self::SUCCESS;
42
    }
43
}
44