@@ -32,7 +32,7 @@ |
||
32 | 32 | */ |
33 | 33 | protected function hosnameAndIp($hostname, $ipAdress) |
34 | 34 | { |
35 | - return $hostname . ($hostname != $ipAdress ? " ({$ipAdress})" : ''); |
|
35 | + return $hostname.($hostname != $ipAdress ? " ({$ipAdress})" : ''); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -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 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | private function makeString($string, $checkSystem) |
99 | 99 | { |
100 | 100 | return ( |
101 | - $string . |
|
101 | + $string. |
|
102 | 102 | ($checkSystem |
103 | 103 | ? config('health.string.ok') |
104 | 104 | : config('health.string.fail')) |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function string() |
135 | 135 | { |
136 | - return collect($this->health())->reduce(function ($current, $resource) { |
|
136 | + return collect($this->health())->reduce(function($current, $resource) { |
|
137 | 137 | return ( |
138 | - $current . |
|
139 | - ($current ? config('health.string.glue') : '') . |
|
138 | + $current. |
|
139 | + ($current ? config('health.string.glue') : ''). |
|
140 | 140 | $this->makeString( |
141 | 141 | $resource->abbreviation, |
142 | 142 | $resource->isHealthy() |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | return instantiate( |
47 | 47 | config( |
48 | - 'health.notifications.channels.' . strtolower($name) . '.sender' |
|
48 | + 'health.notifications.channels.'.strtolower($name).'.sender' |
|
49 | 49 | ) |
50 | 50 | ); |
51 | 51 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | config('health.notifications.from.icon_emoji') |
106 | 106 | ) |
107 | 107 | ->content($this->getMessage()) |
108 | - ->attachment(function ($attachment) { |
|
108 | + ->attachment(function($attachment) { |
|
109 | 109 | $attachment |
110 | 110 | ->title($this->getActionTitle(), $this->getActionLink()) |
111 | 111 | ->content($this->result->errorMessage); |
@@ -29,7 +29,7 @@ |
||
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 |
@@ -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 { |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | return ( |
274 | 274 | $this->notify && |
275 | 275 | config('health.notifications.enabled') && |
276 | - config('health.notifications.notify_on.' . $this->currentAction) |
|
276 | + config('health.notifications.notify_on.'.$this->currentAction) |
|
277 | 277 | ); |
278 | 278 | } |
279 | 279 |
@@ -89,11 +89,11 @@ discard block |
||
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()); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | protected function allResourcesAreGood() |
169 | 169 | { |
170 | 170 | return !$this->getResources() |
171 | - ->reject(function ($resource) { |
|
171 | + ->reject(function($resource) { |
|
172 | 172 | return !$resource instanceof Resource; |
173 | 173 | }) |
174 | 174 | ->isEmpty(); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | protected function getNonGlobalResources() |
184 | 184 | { |
185 | - return $this->getResources()->filter(function (Resource $resource) { |
|
185 | + return $this->getResources()->filter(function(Resource $resource) { |
|
186 | 186 | return !$resource->isGlobal; |
187 | 187 | }); |
188 | 188 | } |
@@ -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 | } |
@@ -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,13 +319,13 @@ 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 | ) { |
327 | 327 | return ( |
328 | - ($resource->isGlobal ? 'a-' : 'z-') . $resource->$sortBy |
|
328 | + ($resource->isGlobal ? 'a-' : 'z-').$resource->$sortBy |
|
329 | 329 | ); |
330 | 330 | }); |
331 | 331 | }); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | private function getNotifiableUsers() |
15 | 15 | { |
16 | 16 | return collect(config('health.notifications.users.emails'))->map( |
17 | - function ($item) { |
|
17 | + function($item) { |
|
18 | 18 | $model = instantiate( |
19 | 19 | config('health.notifications.users.model') |
20 | 20 | ); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | public function handle(RaiseHealthIssue $event) |
36 | 36 | { |
37 | 37 | try { |
38 | - $event->failure->targets->each(function ($target) use ($event) { |
|
38 | + $event->failure->targets->each(function($target) use ($event) { |
|
39 | 39 | if (!$target->result->healthy) { |
40 | 40 | Notification::send( |
41 | 41 | $this->getNotifiableUsers(), |
@@ -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() |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | { |
82 | 82 | $this->publishes( |
83 | 83 | [ |
84 | - __DIR__ . '/config/health.php' => config_path( |
|
84 | + __DIR__.'/config/health.php' => config_path( |
|
85 | 85 | 'health/config.php' |
86 | 86 | ), |
87 | - __DIR__ . '/config/resources/' => config_path( |
|
87 | + __DIR__.'/config/resources/' => config_path( |
|
88 | 88 | 'health/resources/' |
89 | 89 | ), |
90 | 90 | ], |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | $this->publishes( |
95 | 95 | [ |
96 | - __DIR__ . '/resources/views/' => resource_path( |
|
96 | + __DIR__.'/resources/views/' => resource_path( |
|
97 | 97 | 'views/vendor/pragmarx/health/' |
98 | 98 | ), |
99 | 99 | ], |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | |
103 | 103 | $this->publishes( |
104 | 104 | [ |
105 | - __DIR__ . '/database/migrations/' => database_path( |
|
105 | + __DIR__.'/database/migrations/' => database_path( |
|
106 | 106 | 'migrations' |
107 | 107 | ), |
108 | 108 | ], |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | private function configureViews() |
117 | 117 | { |
118 | 118 | $this->loadViewsFrom( |
119 | - realpath(__DIR__ . '/resources/views'), |
|
119 | + realpath(__DIR__.'/resources/views'), |
|
120 | 120 | 'pragmarx/health' |
121 | 121 | ); |
122 | 122 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | $cache = call_user_func($this->cacheClosure); |
132 | 132 | |
133 | - $this->healthServiceClosure = function () use ( |
|
133 | + $this->healthServiceClosure = function() use ( |
|
134 | 134 | $resourceChecker, |
135 | 135 | $cache |
136 | 136 | ) { |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | private function getCacheClosure() |
164 | 164 | { |
165 | - $cacheClosure = function () { |
|
165 | + $cacheClosure = function() { |
|
166 | 166 | return new Cache(); |
167 | 167 | }; |
168 | 168 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | private function getResourceCheckerClosure($resourceLoader, $cache) |
180 | 180 | { |
181 | - $resourceCheckerInstance = function () use ($resourceLoader, $cache) { |
|
181 | + $resourceCheckerInstance = function() use ($resourceLoader, $cache) { |
|
182 | 182 | return new ResourceChecker($resourceLoader, $cache); |
183 | 183 | }; |
184 | 184 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $this->mergeConfigFrom(config_path('/health/config.php'), 'health'); |
229 | 229 | } |
230 | 230 | |
231 | - $this->mergeConfigFrom(__DIR__ . '/config/health.php', 'health'); |
|
231 | + $this->mergeConfigFrom(__DIR__.'/config/health.php', 'health'); |
|
232 | 232 | |
233 | 233 | $this->addDistPathToConfig(); |
234 | 234 | } |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | |
260 | 260 | private function registerResourcesRoutes() |
261 | 261 | { |
262 | - collect($this->resourceLoader->getResources())->each(function ($item) { |
|
262 | + collect($this->resourceLoader->getResources())->each(function($item) { |
|
263 | 263 | if (isset($item['routes'])) { |
264 | - collect($item['routes'])->each(function ($route, $key) { |
|
264 | + collect($item['routes'])->each(function($route, $key) { |
|
265 | 265 | $this->registerRoute($route, $key); |
266 | 266 | }); |
267 | 267 | } |
@@ -275,11 +275,11 @@ discard block |
||
275 | 275 | { |
276 | 276 | $commands = $this->commands; |
277 | 277 | |
278 | - Artisan::command('health:panel', function () use ($commands) { |
|
278 | + Artisan::command('health:panel', function() use ($commands) { |
|
279 | 279 | $commands->panel($this); |
280 | 280 | })->describe('Show all resources and their current health states.'); |
281 | 281 | |
282 | - Artisan::command('health:check', function () use ($commands) { |
|
282 | + Artisan::command('health:check', function() use ($commands) { |
|
283 | 283 | $commands->check($this); |
284 | 284 | })->describe('Check resources health and send error notifications.'); |
285 | 285 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | */ |
298 | 298 | private function registerRoutes() |
299 | 299 | { |
300 | - collect(($routes = $this->getRoutes()))->each(function ($route) { |
|
300 | + collect(($routes = $this->getRoutes()))->each(function($route) { |
|
301 | 301 | $this->registerRoute($route); |
302 | 302 | }); |
303 | 303 | |
@@ -371,6 +371,6 @@ discard block |
||
371 | 371 | |
372 | 372 | public function addDistPathToConfig() |
373 | 373 | { |
374 | - config(['health.dist_path' => __DIR__ . '/resources/dist']); |
|
374 | + config(['health.dist_path' => __DIR__.'/resources/dist']); |
|
375 | 375 | } |
376 | 376 | } |