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

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A prepareKey() 0 8 2
A prepareTtl() 0 8 2
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