Passed
Push — master ( 4925eb...ef22f5 )
by Dawid
02:45
created

isOptional()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiechu\SymfonyCommonsBundle\EventListener;
6
7
use Spiechu\SymfonyCommonsBundle\Service\SchemaValidator\SchemaFilesExistenceChecker;
8
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
9
10
class ControllerSchemaValidationCheckSubscriber implements CacheWarmerInterface
11
{
12
    /**
13
     * @var SchemaFilesExistenceChecker
14
     */
15
    protected $schemaFilesExistenceChecker;
16
17
    /**
18
     * @var bool
19
     */
20
    protected $isDebugMode;
21
22
    /**
23
     * @param SchemaFilesExistenceChecker $schemaFilesExistenceChecker
24
     * @param bool $isDebugMode
25
     */
26 6
    public function __construct(SchemaFilesExistenceChecker $schemaFilesExistenceChecker, bool $isDebugMode)
27
    {
28 6
        $this->schemaFilesExistenceChecker = $schemaFilesExistenceChecker;
29 6
        $this->isDebugMode = $isDebugMode;
30 6
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 6
    public function isOptional(): bool
36
    {
37 6
        return !$this->isDebugMode;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 6
    public function warmUp($cacheDir): void
44
    {
45 6
        $this->schemaFilesExistenceChecker->checkControllerResponseSchemaValidatorFiles();
46 6
    }
47
}
48