1 | <?php |
||
8 | class Service |
||
9 | { |
||
10 | /** |
||
11 | * @var ResourceChecker |
||
12 | */ |
||
13 | private $resourceChecker; |
||
14 | |||
15 | /** |
||
16 | * @var Cache |
||
17 | */ |
||
18 | private $cache; |
||
19 | |||
20 | /** |
||
21 | * Service constructor. |
||
22 | * |
||
23 | * @param ResourceChecker $resourceChecker |
||
24 | * @param Cache $cache |
||
25 | */ |
||
26 | 10 | public function __construct(ResourceChecker $resourceChecker, Cache $cache) |
|
32 | |||
33 | /** |
||
34 | * Check Resources. |
||
35 | * |
||
36 | * @param bool $force |
||
37 | * @return \Illuminate\Support\Collection |
||
38 | * @throws \Exception |
||
39 | */ |
||
40 | 8 | public function checkResources($force = false) |
|
44 | |||
45 | /** |
||
46 | * Check one resource. |
||
47 | * |
||
48 | * @param $slug |
||
49 | * @return array |
||
50 | * @throws \Exception |
||
51 | */ |
||
52 | public function checkResource($slug) |
||
53 | { |
||
54 | return $this->resourceChecker->checkResource($slug); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Get services health. |
||
59 | * |
||
60 | * @return mixed |
||
61 | * @throws \Exception |
||
62 | */ |
||
63 | 2 | public function health() |
|
67 | |||
68 | /** |
||
69 | * Get resources. |
||
70 | * |
||
71 | * @return mixed |
||
72 | * @throws \Exception |
||
73 | */ |
||
74 | public function getResources() |
||
78 | |||
79 | /** |
||
80 | * Get a silent checker and notifier closure. |
||
81 | * |
||
82 | * @return \Closure |
||
83 | */ |
||
84 | 1 | public function getSilentChecker() |
|
90 | |||
91 | /** |
||
92 | * Make a string result of all resources. |
||
93 | * |
||
94 | * @param $string |
||
95 | * @param $checkSystem |
||
96 | * @return string |
||
97 | */ |
||
98 | private function makeString($string, $checkSystem) |
||
99 | { |
||
100 | return ( |
||
101 | $string . |
||
102 | ($checkSystem |
||
103 | ? config('health.string.ok') |
||
104 | : config('health.string.fail')) |
||
105 | ); |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * Check and get a resource. |
||
110 | * |
||
111 | * @param $name |
||
112 | * @return mixed |
||
113 | * @throws \Exception |
||
114 | */ |
||
115 | public function resource($slug) |
||
119 | |||
120 | /** |
||
121 | * Set the action. |
||
122 | * |
||
123 | * @param $action |
||
124 | */ |
||
125 | 1 | public function setAction($action) |
|
129 | |||
130 | /** |
||
131 | * @return mixed |
||
132 | * @throws \Exception |
||
133 | */ |
||
134 | public function string() |
||
147 | } |
||
148 |