Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Pull Request — master (#614)
by Stepan
21:56
created

CompileCacheWarmer   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 92.86%

Importance

Changes 0
Metric Value
wmc 5
eloc 13
dl 0
loc 42
ccs 13
cts 14
cp 0.9286
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isOptional() 0 3 1
A warmUp() 0 13 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\CacheWarmer;
6
7
use Overblog\GraphQLBundle\Generator\TypeGenerator;
8
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
9
10
class CompileCacheWarmer implements CacheWarmerInterface
11
{
12
    private $typeGenerator;
13
14
    private $compiled;
15
16
    /**
17
     * CompileCacheWarmer constructor.
18
     *
19
     * @param TypeGenerator $typeGenerator
20
     * @param bool          $compiled
21
     */
22 36
    public function __construct(TypeGenerator $typeGenerator, $compiled = true)
23
    {
24 36
        $this->typeGenerator = $typeGenerator;
25 36
        $this->compiled = $compiled;
26 36
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 36
    public function isOptional()
32
    {
33 36
        return !$this->compiled;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 35
    public function warmUp($cacheDir): void
40
    {
41 35
        if (!$this->compiled) {
42
          return;
43
        }
44
45
        // use warm up cache dir if type generator cache dir not already explicitly declare
46 35
        $baseCacheDir = $this->typeGenerator->getBaseCacheDir();
47 35
        if (null === $this->typeGenerator->getCacheDir(false)) {
48 35
            $this->typeGenerator->setBaseCacheDir($cacheDir);
49
        }
50 35
        $this->typeGenerator->compile(TypeGenerator::MODE_WRITE | TypeGenerator::MODE_OVERRIDE);
51 32
        $this->typeGenerator->setBaseCacheDir($baseCacheDir);
52 32
    }
53
}
54