GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ClassMetadataPropertiesCacheWarmer::warmUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Ma27\ApiKeyAuthenticationBundle\CacheWarmer;
4
5
use Ma27\ApiKeyAuthenticationBundle\Service\Mapping\Driver\ModelConfigurationDriverInterface;
6
use Symfony\Component\Filesystem\Filesystem;
7
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
8
9
/**
10
 * ClassMetadataPropertiesCacheWarmer is a cache warmer implementation which fills the cache with
11
 * the evaluated result of the properties.
12
 *
13
 * @internal This code is part of the internal API to gather the appropriate model information and shouldn't be used for else use-cases
14
 */
15
class ClassMetadataPropertiesCacheWarmer implements CacheWarmerInterface
16
{
17
    /**
18
     * @var ModelConfigurationDriverInterface
19
     */
20
    private $driver;
21
22
    /**
23
     * @var Filesystem
24
     */
25
    private $filesystem;
26
27
    /**
28
     * Constructor.
29
     *
30
     * @param ModelConfigurationDriverInterface $driver
31
     * @param Filesystem                        $filesystem
32
     */
33 2
    public function __construct(ModelConfigurationDriverInterface $driver, Filesystem $filesystem)
34
    {
35 2
        $this->driver = $driver;
36 2
        $this->filesystem = $filesystem;
37 2
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 2
    public function warmUp($cacheDir)
43
    {
44 2
        $bundleCacheDir = sprintf('%s/ma27_api_key_authentication', $cacheDir);
45
46 2
        $this->filesystem->mkdir($bundleCacheDir);
47 2
        $this->filesystem->touch($filename = sprintf('%s/metadata_dump', $bundleCacheDir));
48 2
        $this->filesystem->dumpFile($filename, $this->buildCacheData());
49 2
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54 1
    public function isOptional()
55
    {
56 1
        return false;
57
    }
58
59
    /**
60
     * Builds the cache data.
61
     *
62
     * @return string
63
     */
64 2
    private function buildCacheData()
65
    {
66 2
        $metadata = $this->driver->getMetadataForUser();
67
68 2
        return serialize(
69 2
            array_map(function (\ReflectionProperty $property) {
70 2
                return $property->getName();
71 2
            }, $metadata)
72
        );
73
    }
74
}
75