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   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 60
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

4 Methods

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