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.
Completed
Push — develop ( 78c84d...9bdc70 )
by Baptiste
04:48
created

CacheLoadAverage::cpu()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Server\Status\Servers\Decorator;
5
6
use Innmind\Server\Status\{
7
    Server,
8
    Server\Cpu,
9
    Server\Memory,
10
    Server\Processes,
11
    Server\LoadAverage,
12
    Server\Disk
13
};
14
use Innmind\TimeContinuum\{
15
    TimeContinuumInterface,
16
    ElapsedPeriod
17
};
18
19 View Code Duplication
final class CacheLoadAverage implements Server
20
{
21
    private $server;
22
    private $clock;
23
    private $threshold;
24
    private $cachedAt;
25
    private $data;
26
27 6
    public function __construct(
28
        Server $server,
29
        TimeContinuumInterface $clock,
30
        ElapsedPeriod $threshold
31
    ) {
32 6
        $this->server = $server;
33 6
        $this->clock = $clock;
34 6
        $this->threshold = $threshold;
35 6
    }
36
37 1
    public function cpu(): Cpu
38
    {
39 1
        return $this->server->cpu();
40
    }
41
42 1
    public function memory(): Memory
43
    {
44 1
        return $this->server->memory();
45
    }
46
47 1
    public function processes(): Processes
48
    {
49 1
        return $this->server->processes();
50
    }
51
52 1
    public function loadAverage(): LoadAverage
53
    {
54 1
        $now = $this->clock->now();
55
56
        if (
57 1
            $this->cachedAt &&
58 1
            $this->threshold->longerThan(
59 1
                $now->elapsedSince($this->cachedAt)
60
            )
61
        ) {
62 1
            return $this->data;
63
        }
64
65 1
        $this->data = $this->server->loadAverage();
66 1
        $this->cachedAt = $now;
67
68 1
        return $this->data;
69
    }
70
71 1
    public function disk(): Disk
72
    {
73 1
        return $this->server->disk();
74
    }
75
}
76