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

CacheCpu::disk()   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 0
Metric Value
dl 4
loc 4
c 0
b 0
f 0
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 CacheCpu 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
        $now = $this->clock->now();
40
41
        if (
42 1
            $this->cachedAt &&
43 1
            $this->threshold->longerThan(
44 1
                $now->elapsedSince($this->cachedAt)
45
            )
46
        ) {
47 1
            return $this->data;
48
        }
49
50 1
        $this->data = $this->server->cpu();
51 1
        $this->cachedAt = $now;
52
53 1
        return $this->data;
54
    }
55
56 1
    public function memory(): Memory
57
    {
58 1
        return $this->server->memory();
59
    }
60
61 1
    public function processes(): Processes
62
    {
63 1
        return $this->server->processes();
64
    }
65
66 1
    public function loadAverage(): LoadAverage
67
    {
68 1
        return $this->server->loadAverage();
69
    }
70
71 1
    public function disk(): Disk
72
    {
73 1
        return $this->server->disk();
74
    }
75
}
76