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

Status::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Actuator\Health;
4
5
/**
6
 * Value object to express state of a component or subsystem.
7
 *
8
 * @package Actuator\Health
9
 */
10
class Status
11
{
12
    /**
13
     * Value representing unknown state.
14
     */
15
    const UNKNOWN = 'UNKNOWN';
16
17
    /**
18
     * Value representing up state.
19
     */
20
    const UP = 'UP';
21
22
    /**
23
     * Value representing down state.
24
     */
25
    const DOWN = 'DOWN';
26
27
    /**
28
     * Value representing out-of-service state.
29
     */
30
    const OUT_OF_SERVICE = 'OUT_OF_SERVICE';
31
32
    /**
33
     * @var string
34
     */
35
    private $code;
36
37
    /**
38
     * @var string
39
     */
40
    private $description;
41
42
    /**
43
     * Create a new Status instance with the given code and description.
44
     *
45
     * @param string $code
46
     * @param string $description
47
     */
48 111
    public function __construct($code, $description = '')
49
    {
50 111
        assert(!is_null($code), 'Code must not be null');
51
52 111
        $this->code = $code;
53 111
        $this->description = $description;
54 111
    }
55
56
    /**
57
     * Return the code for this status.
58
     *
59
     * @return string
60
     */
61 42
    public function getCode()
62
    {
63 42
        return $this->code;
64
    }
65
66
    /**
67
     * Return the description of this status.
68
     *
69
     * @return string
70
     */
71 3
    public function getDescription()
72
    {
73 3
        return $this->description;
74
    }
75
76
    /**
77
     * @return string
78
     */
79 57
    public function __toString()
80
    {
81 57
        return $this->code;
82
    }
83
}
84