FlushCache::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Framework\Console\Commands\Template;
6
7
use AbterPhp\Framework\Template\CacheManager;
8
use Opulence\Console\Commands\Command;
9
use Opulence\Console\Responses\IResponse;
10
11
class FlushCache extends Command
12
{
13
    public const NAME = 'template:flushcache';
14
15
    protected CacheManager $cacheManager;
16
17
    /**
18
     * FlushCacheCommand constructor.
19
     *
20
     * @param CacheManager $cacheManager
21
     */
22
    public function __construct(CacheManager $cacheManager)
23
    {
24
        $this->cacheManager = $cacheManager;
25
26
        parent::__construct();
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32
    protected function define(): void
33
    {
34
        $this->setName(static::NAME)
35
            ->setDescription('Flushes templates')
36
        ;
37
    }
38
39
    /**
40
     * @inheritdoc
41
     */
42
    protected function doExecute(IResponse $response): void
43
    {
44
        $this->cacheManager->flush();
45
        $response->writeln('<info>Template cache is flushed</info>');
46
    }
47
}
48