Passed
Push — master ( f27ff6...85ae0d )
by Paweł
01:57
created

CacheClearCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 8 1
A __construct() 0 3 1
1
<?php
2
3
namespace pjpawel\LightApi\Command\Internal;
4
5
use pjpawel\LightApi\Command\Input\InputInterface;
6
use pjpawel\LightApi\Command\Output\OutputInterface;
7
use pjpawel\LightApi\Component\FilesManager;
8
use pjpawel\LightApi\Component\Serializer;
9
use pjpawel\LightApi\Kernel;
10
use ReflectionClass;
11
12
class CacheClearCommand extends KernelAwareCommand
13
{
14
15
    private FilesManager $filesManager;
16
17
    public function __construct()
18
    {
19
        $this->filesManager = new FilesManager();
20
    }
21
22
    /**
23
     * @inheritDoc
24
     */
25
    public function execute(InputInterface $input, OutputInterface $output): int
26
    {
27
        $reflectionClass = new ReflectionClass(Kernel::class);
28
        /** @var Serializer $serializer */
29
        $serializer = $reflectionClass->getProperty('serializer')->getValue($this->kernel);
30
        $serializerClass = new ReflectionClass($serializer);
31
        $this->filesManager->removeDirRecursive($serializerClass->getProperty('serializedDir')->getValue($serializer));
32
        return self::SUCCESS;
33
    }
34
}