Health   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 1 Features 2
Metric Value
wmc 4
c 5
b 1
f 2
lcom 1
cbo 2
dl 0
loc 56
ccs 11
cts 11
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getStatus() 0 4 1
A getDetails() 0 4 1
A jsonSerialize() 0 6 1
1
<?php
2
3
namespace Actuator\Health;
4
5
/**
6
 * Carries information about the health of a component or subsystem.
7
 */
8
final class Health implements \JsonSerializable
9
{
10
    /**
11
     * @var Status
12
     */
13
    private $status;
14
15
    /**
16
     * @var array
17
     */
18
    private $details;
19
20
    /**
21
     * Create a new Health instance with the specified status and details from builder.
22
     *
23
     * @param HealthBuilder $builder
24
     */
25
    public function __construct(HealthBuilder $builder)
26
    {
27 105
        $this->status = $builder->status;
28
        $this->details = $builder->details;
29 105
    }
30 105
31 105
    /**
32
     * @return Status
33
     */
34
    public function getStatus()
35
    {
36 99
        return $this->status;
37
    }
38 99
39
    /**
40
     * @return array
41
     */
42
    public function getDetails()
43
    {
44 84
        return $this->details;
45
    }
46 84
47
    /**
48
     * Specify data which should be serialized to JSON.
49
     *
50
     * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
51
     *
52
     * @return mixed data which can be serialized by <b>json_encode</b>,
53
     *               which is a value of any type other than a resource.
54
     *
55
     * @since 5.4.0
56 6
     */
57
    public function jsonSerialize()
58 6
    {
59 6
        $merged = array_merge(['status' => $this->status->getCode()], $this->getDetails());
60
61
        return $merged;
62
    }
63
}
64