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.

AbstractMemcachedStore::prepareKey()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
namespace Metaphore\Store;
3
4
abstract class AbstractMemcachedStore
5
{
6
    // when over 30 days, it's treated as unix timestamp (number of seconds
7
    // since January 1, 1970, as an integer), and not a number of seconds
8
    // starting from current time
9
    // http://php.net/manual/en/memcache.set.php
10
    const MAX_TTL = 2592000;
11
12
    // key size is limited
13
    // https://code.google.com/p/memcached/wiki/NewProgrammingTricks#Reducing_key_size
14
    const MAX_KEY_LENGTH = 250;
15
16
    protected function prepareKey($key)
17
    {
18
        if (strlen($key) > self::MAX_KEY_LENGTH) {
19
            $key = substr($key, 0, (self::MAX_KEY_LENGTH - 43)).'___'.sha1($key);
20
        }
21
22
        return $key;
23
    }
24
25
    protected function prepareTtl($ttl)
26
    {
27
        if ($ttl > self::MAX_TTL) {
28
            return (time() + $ttl); // timestamp must be passed if higher than MAX_TTL
29
        }
30
31
        return $ttl;
32
    }
33
}
34