1 | <?php |
||
8 | class HealthBuilder |
||
9 | { |
||
10 | /** |
||
11 | * @var Status |
||
12 | */ |
||
13 | public $status; |
||
14 | |||
15 | /** |
||
16 | * @var array |
||
17 | */ |
||
18 | public $details; |
||
19 | |||
20 | /** |
||
21 | * Create new Builder instance. |
||
22 | * |
||
23 | * @param Status $status |
||
24 | * @param array $details |
||
25 | */ |
||
26 | public function __construct(Status $status = null, $details = []) |
||
35 | 108 | ||
36 | 108 | /** |
|
37 | * Set status to Status::DOWN and add details for given Exception if available. |
||
38 | * |
||
39 | * @param \Exception $exception The exception |
||
40 | * |
||
41 | * @return HealthBuilder |
||
42 | */ |
||
43 | public function down(\Exception $exception = null) |
||
53 | |||
54 | /** |
||
55 | * Create a new Builder instance with a Status::UNKNOWN status. |
||
56 | * |
||
57 | * @return HealthBuilder |
||
58 | */ |
||
59 | public function unknown() |
||
63 | |||
64 | /** |
||
65 | * Create a new Builder instance with a Status::UP status. |
||
66 | * |
||
67 | * @return HealthBuilder |
||
68 | */ |
||
69 | public function up() |
||
73 | |||
74 | /** |
||
75 | * Create a new Builder instance with a Status::OUT_OF_SERVICE status. |
||
76 | * |
||
77 | * @return HealthBuilder |
||
78 | */ |
||
79 | public function outOfService() |
||
83 | |||
84 | /** |
||
85 | * Set status to given Status instance or status code. |
||
86 | * |
||
87 | * @param Status|string $status |
||
88 | * |
||
89 | * @return $this |
||
90 | */ |
||
91 | 90 | public function status($status) |
|
101 | |||
102 | /** |
||
103 | * Record detail for given {@link Exception}. |
||
104 | * |
||
105 | * @param \Exception $exception |
||
106 | * |
||
107 | 18 | * @return $this |
|
108 | */ |
||
109 | 18 | public function withException(\Exception $exception) |
|
115 | |||
116 | /** |
||
117 | * Record detail using key and message. |
||
118 | * |
||
119 | * @param string $key the detail key |
||
120 | 57 | * @param mixed $message the detail message |
|
121 | * |
||
122 | 57 | * @return $this |
|
123 | 57 | */ |
|
124 | 57 | public function withDetail($key, $message) |
|
132 | |||
133 | 105 | /** |
|
134 | * @return Health |
||
135 | */ |
||
136 | public function build() |
||
140 | } |
||
141 |