Total Complexity | 7 |
Total Lines | 104 |
Duplicated Lines | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | class Result |
||
6 | { |
||
7 | /** |
||
8 | * Healthy |
||
9 | */ |
||
10 | const STATUS_PASS = 'pass'; |
||
11 | |||
12 | /** |
||
13 | * Healthy, with some concerns |
||
14 | */ |
||
15 | const STATUS_WARN = 'warn'; |
||
16 | |||
17 | /** |
||
18 | * Unhealthy |
||
19 | */ |
||
20 | const STATUS_FAIL = 'fail'; |
||
21 | |||
22 | private static $statuses = [ |
||
23 | self::STATUS_PASS => 0, |
||
24 | self::STATUS_WARN => 50, |
||
25 | self::STATUS_FAIL => 100 |
||
26 | ]; |
||
27 | |||
28 | const LIMIT_TYPE_MIN = 'min'; |
||
29 | const LIMIT_TYPE_MAX = 'max'; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $status; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | private $message; |
||
40 | |||
41 | /** |
||
42 | * @var array |
||
43 | */ |
||
44 | private $attributes = []; |
||
45 | |||
46 | /** |
||
47 | * Result constructor. |
||
48 | * |
||
49 | * @param $status |
||
50 | * @param $message |
||
51 | */ |
||
52 | public function __construct($status, $message = "") |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return string |
||
60 | */ |
||
61 | public function getStatus() |
||
62 | { |
||
63 | return $this->status; |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @return string |
||
68 | */ |
||
69 | public function getMessage() |
||
70 | { |
||
71 | return $this->message; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Add a new attribute to the result. |
||
76 | * |
||
77 | * @param string $key |
||
78 | * @param mixed $value |
||
79 | */ |
||
80 | public function addAttribute($key, $value) |
||
81 | { |
||
82 | $this->attributes[$key] = $value; |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * Return a list of attribute |
||
87 | * |
||
88 | * @return array |
||
89 | */ |
||
90 | public function getAttributes() |
||
91 | { |
||
92 | return $this->attributes; |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * Returns the higher weighted status. |
||
97 | * |
||
98 | * @param $status1 |
||
99 | * @param $status2 |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | public static function getHigherWeightedStatus($status1, $status2) |
||
109 | } |
||
110 | } |
||
111 | } |
||
112 |