Completed
Push — master ( ee6112...f2efac )
by John
15:02
created

Health::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 5
ccs 0
cts 0
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 2
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 18
    public function __construct(HealthBuilder $builder)
28
    {
29 18
        $this->status = $builder->status;
30 18
        $this->details = $builder->details;
31 18
    }
32 18
33
    /**
34
     * @return Status
35
     */
36
    public function getStatus()
37 18
    {
38
        return $this->status;
39 18
    }
40
41
    /**
42
     * @return array
43
     */
44
    public function getDetails()
45 6
    {
46
        return $this->details;
47 6
    }
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
    public function jsonSerialize()
57
    {
58
        $merged = array_merge(['status' => $this->status->getCode()], $this->getDetails());
59
        return $merged;
60
    }
61
}
62