Test Failed
Push — master ( 8056b0...16429a )
by Paweł
02:11
created

CacheClearCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 11 2
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\Serializer;
8
use pjpawel\LightApi\Kernel;
9
use ReflectionClass;
10
11
class CacheClearCommand extends KernelAwareCommand
12
{
13
14
    /**
15
     * @inheritDoc
16
     */
17
    public function execute(InputInterface $input, OutputInterface $output): int
18
    {
19
        $reflectionClass = new ReflectionClass(Kernel::class);
20
        /** @var Serializer $serializer */
21
        $serializer = $reflectionClass->getProperty('serializer')->getValue($this->kernel);
22
        $serializerClass = new ReflectionClass($serializer);
23
        if (rmdir($serializerClass->getProperty('serializedDir')->getValue($serializer))) {
24
            throw new \Exception('Cannot remove dir: ' .
25
                $serializerClass->getProperty('serializedDir')->getValue($serializer));
26
        }
27
        return self::SUCCESS;
28
    }
29
}