Completed
Branch master (f2efac)
by John
02:31
created

Health   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 2
Metric Value
wmc 4
c 4
b 0
f 2
lcom 1
cbo 2
dl 0
loc 52
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 5 1
1
<?php
2
3
namespace Actuator\Health;
4
5
/**
6
 * Carries information about the health of a component or subsystem.
7
 *
8
 * @package Actuator\Health
9
 */
10
final class Health implements \JsonSerializable
11
{
12
    /**
13
     * @var Status
14
     */
15
    private $status;
16
17
    /**
18
     * @var array
19
     */
20
    private $details;
21
22
    /**
23
     * Create a new Health instance with the specified status and details from builder.
24
     *
25
     * @param HealthBuilder $builder
26
     */
27 105
    public function __construct(HealthBuilder $builder)
28
    {
29 105
        $this->status = $builder->status;
30 105
        $this->details = $builder->details;
31 105
    }
32
33
    /**
34
     * @return Status
35
     */
36 99
    public function getStatus()
37
    {
38 99
        return $this->status;
39
    }
40
41
    /**
42
     * @return array
43
     */
44 84
    public function getDetails()
45
    {
46 84
        return $this->details;
47
    }
48
49
    /**
50
     * Specify data which should be serialized to JSON
51
     * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
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
     * @since 5.4.0
55
     */
56 6
    public function jsonSerialize()
57
    {
58 6
        $merged = array_merge(['status' => $this->status->getCode()], $this->getDetails());
59 6
        return $merged;
60
    }
61
}
62