Status::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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