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.

SplObjectHashKeyGenerator::generateKey()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace EmanueleMinotto\TwigCacheBundle\KeyGenerator;
4
5
use Asm89\Twig\CacheExtension\CacheStrategy\KeyGeneratorInterface;
6
7
/**
8
 * Key generator based on spl_object_hash.
9
 *
10
 * @see https://github.com/asm89/twig-cache-extension#setup-1
11
 */
12
class SplObjectHashKeyGenerator implements KeyGeneratorInterface
13
{
14
    /**
15
     * Generate a cache key for a given value.
16
     *
17
     * @param mixed $value cached value
18
     *
19
     * @return string
20
     */
21
    public function generateKey($value)
22
    {
23
        if (is_object($value)) {
24
            return spl_object_hash($value);
25
        }
26
27
        return sha1(serialize($value));
28
    }
29
}
30