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

ControllerSchemaValidationCheckSubscriber   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 2
cbo 1
dl 0
loc 38
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A isOptional() 0 4 1
A warmUp() 0 4 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