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.

Ttl::getTtl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Metaphore;
3
4
/**
5
 * Time-to-live value object.
6
 */
7
class Ttl
8
{
9
    const DEFAULT_GRACE_TTL = 60;
10
11
    const DEFAULT_LOCK_TTL = 5;
12
13
    /*** @var int */
14
    protected $ttl;
15
16
    /*** @var int How long to serve stale content while new one is being generated */
17
    protected $graceTtl;
18
19
    /*** @var int How long to prevent other requests to start generating same content */
20
    protected $lockTtl;
21
22
    /**
23
     * @param int
24
     * @param int Grace period
25
     * @param int
26
     */
27
    public function __construct($ttl, $graceTtl = null, $lockTtl = null)
28
    {
29
        $this->ttl = (int)$ttl;
30
31
        if (isset($graceTtl)) {
32
            $this->graceTtl = (int)$graceTtl;
33
        }
34
35
        if (isset($lockTtl)) {
36
            $this->lockTtl = (int)$lockTtl;
37
        }
38
    }
39
40
    /**
41
     * @return int
42
     */
43
    public function getTtl()
44
    {
45
        return $this->ttl;
46
    }
47
48
    /**
49
     * Get time how log it's really cached in cache store.
50
     *
51
     * @return int
52
     */
53
    public function getRealTtl()
54
    {
55
        // $grace_ttl added, so stale result might be served if needed
56
        return ($this->getTtl() + $this->getGraceTtl());
57
    }
58
59
    /**
60
     * Gets grace period
61
     *
62
     * @return int
63
     */
64
    public function getGraceTtl()
65
    {
66
        if (!isset($this->graceTtl)) {
67
            $this->graceTtl = self::DEFAULT_GRACE_TTL;
68
        }
69
70
        return $this->graceTtl;
71
    }
72
73
    /**
74
     * @return int
75
     */
76
    public function getLockTtl()
77
    {
78
        if (!isset($this->lockTtl)) {
79
            $this->lockTtl = self::DEFAULT_LOCK_TTL;
80
        }
81
82
        return $this->lockTtl;
83
    }
84
85
    public function __toString()
86
    {
87
        return (string)$this->getTtl();
88
    }
89
}
90