@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * Format input to textual table. |
101 | 101 | * |
102 | 102 | * @param Command|null $command |
103 | - * @param $columns |
|
103 | + * @param string[] $columns |
|
104 | 104 | * @param \Illuminate\Contracts\Support\Arrayable|array $rows |
105 | 105 | */ |
106 | 106 | private function table($command, $columns, $rows) |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * Write a string as information output. |
115 | 115 | * |
116 | 116 | * @param Command|null $command |
117 | - * @param $string |
|
117 | + * @param string $string |
|
118 | 118 | */ |
119 | 119 | private function info($command, $string) |
120 | 120 | { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * Write a string as information output. |
128 | 128 | * |
129 | 129 | * @param Command|null $command |
130 | - * @param $string |
|
130 | + * @param string $string |
|
131 | 131 | */ |
132 | 132 | private function error($command, $string) |
133 | 133 | { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $columns = ['Resource', 'State', 'Message']; |
59 | 59 | |
60 | 60 | $rows = $this->getTargetsFomResources($this->healthService->health()) |
61 | - ->map(function ($target) { |
|
61 | + ->map(function($target) { |
|
62 | 62 | return [ |
63 | 63 | "{$target->resource->name} ({$target->display})", |
64 | 64 | $target->result->healthy |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | { |
77 | 77 | $checker = $this->healthService->getSilentChecker(); |
78 | 78 | |
79 | - $errors = $this->getTargetsFomResources($checker()->filter(function ($resource) { |
|
80 | - return ! $resource->isGlobal; |
|
81 | - }))->reduce(function ($carry, $target) { |
|
79 | + $errors = $this->getTargetsFomResources($checker()->filter(function($resource) { |
|
80 | + return !$resource->isGlobal; |
|
81 | + }))->reduce(function($carry, $target) { |
|
82 | 82 | return $carry + ($target->result->healthy ? 0 : 1); |
83 | 83 | }, 0); |
84 | 84 |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * Check and get one resource. |
41 | 41 | * |
42 | - * @param $slug |
|
42 | + * @param string $slug |
|
43 | 43 | * @return mixed |
44 | 44 | * @throws \Exception |
45 | 45 | */ |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * Get all resources. |
55 | 55 | * |
56 | - * @return mixed |
|
56 | + * @return \Illuminate\Support\Collection |
|
57 | 57 | * @throws \Exception |
58 | 58 | */ |
59 | 59 | public function allResources() |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function getSilentChecker() |
85 | 85 | { |
86 | - return function () { |
|
86 | + return function() { |
|
87 | 87 | return $this->checkResources(); |
88 | 88 | }; |
89 | 89 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function string() |
134 | 134 | { |
135 | - return collect($this->health())->reduce(function ($current, $resource) { |
|
135 | + return collect($this->health())->reduce(function($current, $resource) { |
|
136 | 136 | return |
137 | 137 | $current. |
138 | 138 | ($current ? config('health.string.glue') : ''). |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | /** |
133 | 133 | * Get the action message. |
134 | 134 | * |
135 | - * @param $item |
|
136 | - * @return \Illuminate\Config\Repository|mixed |
|
135 | + * @param HealthStatus $item |
|
136 | + * @return string |
|
137 | 137 | */ |
138 | 138 | private function getActionMessage($item) |
139 | 139 | { |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | /** |
146 | 146 | * Get the action title. |
147 | 147 | * |
148 | - * @return mixed |
|
148 | + * @return string |
|
149 | 149 | */ |
150 | 150 | protected function getActionTitle() |
151 | 151 | { |
@@ -103,7 +103,7 @@ |
||
103 | 103 | config('health.notifications.from.icon_emoji') |
104 | 104 | ) |
105 | 105 | ->content($this->getMessage()) |
106 | - ->attachment(function ($attachment) { |
|
106 | + ->attachment(function($attachment) { |
|
107 | 107 | $attachment |
108 | 108 | ->title($this->getActionTitle(), $this->getActionLink()) |
109 | 109 | ->content($this->result->errorMessage); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * Resource factory. |
88 | 88 | * |
89 | 89 | * @param Collection $data |
90 | - * @return resource |
|
90 | + * @return Resource |
|
91 | 91 | * @throws \Exception |
92 | 92 | */ |
93 | 93 | public static function factory(Collection $data) |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * Check all targets for a resource. |
177 | 177 | * |
178 | 178 | * @param string $action |
179 | - * @return resource |
|
179 | + * @return Resource |
|
180 | 180 | */ |
181 | 181 | public function check($action = 'resource') |
182 | 182 | { |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * Check global resources. |
196 | 196 | * |
197 | 197 | * @param $resources |
198 | - * @return resource |
|
198 | + * @return Resource |
|
199 | 199 | */ |
200 | 200 | public function checkGlobal($resources) |
201 | 201 | { |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | /** |
235 | 235 | * Send notifications. |
236 | 236 | * |
237 | - * @return static |
|
237 | + * @return Collection |
|
238 | 238 | */ |
239 | 239 | protected function sendNotifications() |
240 | 240 | { |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * Set current action. |
280 | 280 | * |
281 | 281 | * @param string $currentAction |
282 | - * @return resource |
|
282 | + * @return Resource |
|
283 | 283 | */ |
284 | 284 | public function setCurrentAction(string $currentAction) |
285 | 285 | { |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * Resources setter. |
293 | 293 | * |
294 | 294 | * @param $resources |
295 | - * @return resource |
|
295 | + * @return Resource |
|
296 | 296 | */ |
297 | 297 | protected function setResources($resources) |
298 | 298 | { |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | $current = collect(); |
146 | 146 | |
147 | 147 | $targets = $targets |
148 | - ->map(function (Collection $targetList) { |
|
149 | - return $targetList->map(function ($target, $name) { |
|
148 | + ->map(function(Collection $targetList) { |
|
149 | + return $targetList->map(function($target, $name) { |
|
150 | 150 | return Target::factory($this, $target, $name); |
151 | 151 | }); |
152 | 152 | }) |
153 | - ->reduce(function ($current, $targetList) { |
|
153 | + ->reduce(function($current, $targetList) { |
|
154 | 154 | foreach ($targetList as $target) { |
155 | 155 | $current[] = $target; |
156 | 156 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function check($action = 'resource') |
182 | 182 | { |
183 | - $this->setCurrentAction($action)->targets->each(function ( |
|
183 | + $this->setCurrentAction($action)->targets->each(function( |
|
184 | 184 | Target $target |
185 | 185 | ) { |
186 | 186 | $target->check($target); |
@@ -209,14 +209,14 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function isHealthy() |
211 | 211 | { |
212 | - return $this->targets->reduce(function ($carry, $target) { |
|
212 | + return $this->targets->reduce(function($carry, $target) { |
|
213 | 213 | return $carry && $target->result->healthy; |
214 | 214 | }, true); |
215 | 215 | } |
216 | 216 | |
217 | 217 | protected function keysToCamel($array) |
218 | 218 | { |
219 | - return collect($array)->mapWithKeys(function ($item, $key) { |
|
219 | + return collect($array)->mapWithKeys(function($item, $key) { |
|
220 | 220 | return [camel_case($key) => $item]; |
221 | 221 | }); |
222 | 222 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | protected function sendNotifications() |
240 | 240 | { |
241 | - return collect(config('health.notifications.channels'))->each(function ( |
|
241 | + return collect(config('health.notifications.channels'))->each(function( |
|
242 | 242 | $channel |
243 | 243 | ) { |
244 | 244 | try { |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | protected function canNotify() |
258 | 258 | { |
259 | 259 | return |
260 | - ! $this->notified && |
|
260 | + !$this->notified && |
|
261 | 261 | $this->notificationsAreEnabled() && |
262 | - ! $this->isHealthy(); |
|
262 | + !$this->isHealthy(); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | /** |
153 | 153 | * Get current action. |
154 | 154 | * |
155 | - * @return mixed |
|
155 | + * @return string |
|
156 | 156 | */ |
157 | 157 | public function getCurrentAction() |
158 | 158 | { |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * Get one resource. |
299 | 299 | * |
300 | 300 | * @param resource|Collection $resource |
301 | - * @return resource |
|
301 | + * @return Resource |
|
302 | 302 | * @throws Exception |
303 | 303 | */ |
304 | 304 | public function makeResource($resource) |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | /** |
314 | 314 | * Sort resources. |
315 | 315 | * |
316 | - * @param $resources |
|
316 | + * @param Collection $resources |
|
317 | 317 | * @return \Illuminate\Support\Collection |
318 | 318 | */ |
319 | 319 | protected function sortResources($resources) |
@@ -79,21 +79,21 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function checkResources($force = false) |
81 | 81 | { |
82 | - if (! ($resources = $this->getCachedResources($force))->isEmpty()) { |
|
82 | + if (!($resources = $this->getCachedResources($force))->isEmpty()) { |
|
83 | 83 | return $resources; |
84 | 84 | } |
85 | 85 | |
86 | - if (! $this->allResourcesAreGood()) { |
|
86 | + if (!$this->allResourcesAreGood()) { |
|
87 | 87 | return $this->resources = collect(); |
88 | 88 | } |
89 | 89 | |
90 | 90 | $resources = $this->sortResources( |
91 | 91 | $this->getNonGlobalResources() |
92 | - ->each(function ($resource) { |
|
92 | + ->each(function($resource) { |
|
93 | 93 | $this->checkResource($resource); |
94 | 94 | }) |
95 | 95 | ->merge( |
96 | - $this->getGlobalResources()->each(function ($resource) { |
|
96 | + $this->getGlobalResources()->each(function($resource) { |
|
97 | 97 | return $resource->checkGlobal($this->getResources()); |
98 | 98 | }) |
99 | 99 | ) |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | ? $resource |
119 | 119 | : $this->getResourceBySlug($resource); |
120 | 120 | |
121 | - $checked = $this->cache->remember($resource->slug, function () use ( |
|
121 | + $checked = $this->cache->remember($resource->slug, function() use ( |
|
122 | 122 | $resource |
123 | 123 | ) { |
124 | 124 | return $resource->check($this->getCurrentAction()); |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | */ |
168 | 168 | protected function allResourcesAreGood() |
169 | 169 | { |
170 | - return ! $this->getResources() |
|
171 | - ->reject(function ($resource) { |
|
172 | - return ! $resource instanceof Resource; |
|
170 | + return !$this->getResources() |
|
171 | + ->reject(function($resource) { |
|
172 | + return !$resource instanceof Resource; |
|
173 | 173 | }) |
174 | 174 | ->isEmpty(); |
175 | 175 | } |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | */ |
183 | 183 | protected function getNonGlobalResources() |
184 | 184 | { |
185 | - return $this->getResources()->filter(function (Resource $resource) { |
|
186 | - return ! $resource->isGlobal; |
|
185 | + return $this->getResources()->filter(function(Resource $resource) { |
|
186 | + return !$resource->isGlobal; |
|
187 | 187 | }); |
188 | 188 | } |
189 | 189 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | protected function getGlobalResources() |
197 | 197 | { |
198 | - return $this->getResources()->filter(function (Resource $resource) { |
|
198 | + return $this->getResources()->filter(function(Resource $resource) { |
|
199 | 199 | return $resource->isGlobal; |
200 | 200 | }); |
201 | 201 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | ? $exception->getMessage() |
228 | 228 | : static::UNKNOWN_ERROR; |
229 | 229 | |
230 | - if (! isset($resourceChecker)) { |
|
230 | + if (!isset($resourceChecker)) { |
|
231 | 231 | return [ |
232 | 232 | null, |
233 | 233 | [ |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | { |
284 | 284 | if (is_null($this->resources) || $this->resources->isEmpty()) { |
285 | 285 | $this->resources = $this->resourceLoader->loadResources()->map( |
286 | - function ($resource) { |
|
287 | - return $this->handleExceptions(function () use ($resource) { |
|
286 | + function($resource) { |
|
287 | + return $this->handleExceptions(function() use ($resource) { |
|
288 | 288 | return $this->makeResource($resource); |
289 | 289 | }); |
290 | 290 | } |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | protected function sortResources($resources) |
320 | 320 | { |
321 | 321 | if ($sortBy = config('health.sort_by')) { |
322 | - return $resources->sortBy(function ($resource) use ($sortBy) { |
|
323 | - return $this->handleExceptions(function () use ( |
|
322 | + return $resources->sortBy(function($resource) use ($sortBy) { |
|
323 | + return $this->handleExceptions(function() use ( |
|
324 | 324 | $resource, |
325 | 325 | $sortBy |
326 | 326 | ) { |
@@ -25,11 +25,11 @@ |
||
25 | 25 | */ |
26 | 26 | protected function horizonIsRunning() |
27 | 27 | { |
28 | - if (! $masters = app(MasterSupervisorRepository::class)->all()) { |
|
28 | + if (!$masters = app(MasterSupervisorRepository::class)->all()) { |
|
29 | 29 | return false; |
30 | 30 | } |
31 | 31 | |
32 | - return collect($masters)->contains(function ($master) { |
|
32 | + return collect($masters)->contains(function($master) { |
|
33 | 33 | return $master->status === 'paused'; |
34 | 34 | }) |
35 | 35 | ? false |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | private function getResources($force = false) |
145 | 145 | { |
146 | - if ($force || ! $this->resources) { |
|
146 | + if ($force || !$this->resources) { |
|
147 | 147 | $this->resources = $this->service->checkResources($force); |
148 | 148 | } |
149 | 149 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | |
222 | 222 | public function assertCheckedResources($resources) |
223 | 223 | { |
224 | - $healthCount = $resources->reduce(function ($carry, $resource) { |
|
224 | + $healthCount = $resources->reduce(function($carry, $resource) { |
|
225 | 225 | return $carry + ($resource->isHealthy() ? 1 : 0); |
226 | 226 | }, 0); |
227 | 227 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $healthCount |
231 | 231 | ); |
232 | 232 | |
233 | - $failing = $resources->filter(function ($resource) { |
|
233 | + $failing = $resources->filter(function($resource) { |
|
234 | 234 | return $resource->isHealthy(); |
235 | 235 | }); |
236 | 236 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | { |
258 | 258 | $this->assertEquals( |
259 | 259 | collect(static::ALL_RESOURCES) |
260 | - ->map(function ($value) { |
|
260 | + ->map(function($value) { |
|
261 | 261 | return strtolower($value); |
262 | 262 | }) |
263 | 263 | ->sort() |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | ->toArray(), |
266 | 266 | $this->getResources() |
267 | 267 | ->keys() |
268 | - ->map(function ($value) { |
|
268 | + ->map(function($value) { |
|
269 | 269 | return strtolower($value); |
270 | 270 | }) |
271 | 271 | ->sort() |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | (new Commands($this->service))->$command(); |
283 | 283 | } |
284 | 284 | |
285 | - $this->assertFalse(! true); |
|
285 | + $this->assertFalse(!true); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | public function testController() |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace PragmaRX\Health\Checkers; |
4 | 4 | |
5 | -use Illuminate\Queue\Worker; |
|
6 | 5 | use Illuminate\Queue\WorkerOptions; |
7 | 6 | use PragmaRX\Health\Support\Result; |
8 | 7 |