Passed
Push — master ( e32a81...12baf4 )
by Antonio Carlos
02:26
created

ServerLoad   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
dl 0
loc 36
ccs 15
cts 18
cp 0.8333
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A check() 0 11 3
A makeMessage() 0 16 3
1
<?php
2
3
namespace PragmaRX\Health\Checkers;
4
5
use PragmaRX\Health\Support\Result;
6
7
class ServerLoad extends ServerUptime
8
{
9
    /**
10
     * Check resource.
11
     *
12
     * @return Result
13
     */
14 1
    public function check()
15
    {
16 1
        $current = $this->getCurrentUptime();
17
18
        $inTrouble =
19 1
            $current['load_1'] > $this->target->maxLoad['load_1'] ||
0 ignored issues
show
Bug introduced by
The property maxLoad does not seem to exist in PragmaRX\Health\Support\Target.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
20
            $current['load_5'] > $this->target->maxLoad['load_5'] ||
21 1
            $current['load_15'] > $this->target->maxLoad['load_15'];
22
23 1
        return $this->makeResult(! $inTrouble, $this->makeMessage($current));
24
    }
25
26 1
    protected function makeMessage($current, $saved = null)
27
    {
28 1
        $current['load_1'] > $this->target->maxLoad['load_1'] ||
0 ignored issues
show
Bug introduced by
The property maxLoad does not seem to exist in PragmaRX\Health\Support\Target.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
29
            $current['load_5'] > $this->target->maxLoad['load_5'] ||
30
            $current['load_15'] > $this->target->maxLoad['load_15'];
31
32 1
        return sprintf(
33 1
            $this->target->getErrorMessage(),
34 1
            $current['load_1'],
35 1
            $current['load_5'],
36 1
            $current['load_15'],
37 1
            $this->target->maxLoad['load_1'],
38 1
            $this->target->maxLoad['load_5'],
39 1
            $this->target->maxLoad['load_15']
40
        );
41
    }
42
}
43