@@ -9,7 +9,7 @@ |
||
9 | 9 | class NotifyHealthIssue |
10 | 10 | { |
11 | 11 | /** |
12 | - * @return static |
|
12 | + * @return \Illuminate\Support\Collection |
|
13 | 13 | */ |
14 | 14 | private function getNotifiableUsers() |
15 | 15 | { |
@@ -14,7 +14,7 @@ |
||
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 | ); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * Format input to textual table. |
121 | 121 | * |
122 | 122 | * @param Command|null $command |
123 | - * @param $columns |
|
123 | + * @param string[] $columns |
|
124 | 124 | * @param \Illuminate\Contracts\Support\Arrayable|array $rows |
125 | 125 | */ |
126 | 126 | private function table($command, $columns, $rows) |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * Write a string as information output. |
135 | 135 | * |
136 | 136 | * @param Command|null $command |
137 | - * @param $string |
|
137 | + * @param string $string |
|
138 | 138 | */ |
139 | 139 | private function info($command, $string) |
140 | 140 | { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * Write a string as information output. |
148 | 148 | * |
149 | 149 | * @param Command|null $command |
150 | - * @param $string |
|
150 | + * @param string $string |
|
151 | 151 | */ |
152 | 152 | private function error($command, $string) |
153 | 153 | { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * Write a string as information output. |
161 | 161 | * |
162 | 162 | * @param Command|null $command |
163 | - * @param $string |
|
163 | + * @param string $string |
|
164 | 164 | */ |
165 | 165 | private function warn($command, $string) |
166 | 166 | { |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $columns = ['Resource', 'State', 'Message']; |
42 | 42 | |
43 | 43 | $rows = $this->healthService->health() |
44 | - ->map(function ($resource) { |
|
44 | + ->map(function($resource) { |
|
45 | 45 | return [ |
46 | 46 | $resource['name'], |
47 | 47 | $resource['health']['healthy'] |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | $errors = $checker() |
63 | 63 | ->where('is_global', false) |
64 | - ->reduce(function ($carry, $item) { |
|
64 | + ->reduce(function($carry, $item) { |
|
65 | 65 | return $carry + ($item['health']['healthy'] ? 0 : 1); |
66 | 66 | }, 0); |
67 | 67 | |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | if ($errors) { |
71 | 71 | $this->error( |
72 | 72 | $command, |
73 | - "Application needs attention, $errors " . |
|
74 | - str_plural('resouce', $errors) . |
|
75 | - ' ' . |
|
76 | - ($errors > 1 ? 'are' : 'is') . |
|
73 | + "Application needs attention, $errors ". |
|
74 | + str_plural('resouce', $errors). |
|
75 | + ' '. |
|
76 | + ($errors > 1 ? 'are' : 'is'). |
|
77 | 77 | ' currently failing.' |
78 | 78 | ); |
79 | 79 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | { |
90 | 90 | $yaml = new Yaml(); |
91 | 91 | |
92 | - collect(config('health.resources'))->each(function ( |
|
92 | + collect(config('health.resources'))->each(function( |
|
93 | 93 | $resource, |
94 | 94 | $key |
95 | 95 | ) use ($command, $yaml) { |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | |
108 | 108 | file_put_contents( |
109 | 109 | $file = |
110 | - $path . DIRECTORY_SEPARATOR . studly_case($key) . '.yml', |
|
110 | + $path.DIRECTORY_SEPARATOR.studly_case($key).'.yml', |
|
111 | 111 | $dump |
112 | 112 | ); |
113 | 113 | |
114 | - $this->info($command, 'Exported ' . $file); |
|
114 | + $this->info($command, 'Exported '.$file); |
|
115 | 115 | }); |
116 | 116 | } |
117 | 117 | |
@@ -121,24 +121,24 @@ discard block |
||
121 | 121 | |
122 | 122 | $yaml |
123 | 123 | ->loadFromDirectory(package_resources_dir(), false) |
124 | - ->each(function ($value, $key) use ($command, $yaml) { |
|
124 | + ->each(function($value, $key) use ($command, $yaml) { |
|
125 | 125 | if (!file_exists($path = config('health.resources.path'))) { |
126 | 126 | mkdir($path, 0755, true); |
127 | 127 | } |
128 | 128 | |
129 | 129 | if ( |
130 | 130 | file_exists( |
131 | - $file = $path . DIRECTORY_SEPARATOR . $key . '.yaml' |
|
131 | + $file = $path.DIRECTORY_SEPARATOR.$key.'.yaml' |
|
132 | 132 | ) |
133 | 133 | ) { |
134 | - $this->warn($command, 'Skipped: ' . $file); |
|
134 | + $this->warn($command, 'Skipped: '.$file); |
|
135 | 135 | |
136 | 136 | return; |
137 | 137 | } |
138 | 138 | |
139 | 139 | file_put_contents($file, $yaml->dump($value)); |
140 | 140 | |
141 | - $this->info($command, 'Saved: ' . $file); |
|
141 | + $this->info($command, 'Saved: '.$file); |
|
142 | 142 | }); |
143 | 143 | } |
144 | 144 |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | /** |
143 | 143 | * Get the resource checker closure for instantiation. |
144 | 144 | * |
145 | - * @param $resourceLoader |
|
145 | + * @param ResourceLoader $resourceLoader |
|
146 | 146 | * @param $cache |
147 | 147 | * @return \Closure |
148 | 148 | */ |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | /** |
355 | 355 | * Get the services provided by the provider. |
356 | 356 | * |
357 | - * @return array |
|
357 | + * @return string[] |
|
358 | 358 | */ |
359 | 359 | public function provides() |
360 | 360 | { |
@@ -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 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | */ |
189 | 189 | private function getResourceCheckerClosure($resourceLoader, $cache) |
190 | 190 | { |
191 | - $resourceCheckerInstance = function () use ($resourceLoader, $cache) { |
|
191 | + $resourceCheckerInstance = function() use ($resourceLoader, $cache) { |
|
192 | 192 | return new ResourceChecker($resourceLoader, $cache); |
193 | 193 | }; |
194 | 194 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $this->mergeConfigFrom(config_path('/health/config.php'), 'health'); |
239 | 239 | } |
240 | 240 | |
241 | - $this->mergeConfigFrom(__DIR__ . '/config/health.php', 'health'); |
|
241 | + $this->mergeConfigFrom(__DIR__.'/config/health.php', 'health'); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | |
268 | 268 | private function registerResourcesRoutes() |
269 | 269 | { |
270 | - collect($this->resourceLoader->getResources())->each(function ($item) { |
|
270 | + collect($this->resourceLoader->getResources())->each(function($item) { |
|
271 | 271 | if (isset($item['routes'])) { |
272 | - collect($item['routes'])->each(function ($route, $key) { |
|
272 | + collect($item['routes'])->each(function($route, $key) { |
|
273 | 273 | $this->registerRoute($route, $key); |
274 | 274 | }); |
275 | 275 | } |
@@ -283,19 +283,19 @@ discard block |
||
283 | 283 | { |
284 | 284 | $commands = $this->commands; |
285 | 285 | |
286 | - Artisan::command('health:panel', function () use ($commands) { |
|
286 | + Artisan::command('health:panel', function() use ($commands) { |
|
287 | 287 | $commands->panel($this); |
288 | 288 | })->describe('Show all resources and their current health states.'); |
289 | 289 | |
290 | - Artisan::command('health:check', function () use ($commands) { |
|
290 | + Artisan::command('health:check', function() use ($commands) { |
|
291 | 291 | $commands->check($this); |
292 | 292 | })->describe('Check resources health and send error notifications.'); |
293 | 293 | |
294 | - Artisan::command('health:export', function () use ($commands) { |
|
294 | + Artisan::command('health:export', function() use ($commands) { |
|
295 | 295 | $commands->export($this); |
296 | 296 | })->describe('Export "array" resources to .yml files'); |
297 | 297 | |
298 | - Artisan::command('health:publish', function () use ($commands) { |
|
298 | + Artisan::command('health:publish', function() use ($commands) { |
|
299 | 299 | $commands->publish($this); |
300 | 300 | })->describe('Publish all .yml resouces files to config directory.'); |
301 | 301 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | */ |
314 | 314 | private function registerRoutes() |
315 | 315 | { |
316 | - collect($routes = $this->getRoutes())->each(function ($route) { |
|
316 | + collect($routes = $this->getRoutes())->each(function($route) { |
|
317 | 317 | $this->registerRoute($route); |
318 | 318 | }); |
319 | 319 |
@@ -161,6 +161,9 @@ |
||
161 | 161 | $this->assertTrue($resource->first()['name'] == 'Database'); |
162 | 162 | } |
163 | 163 | |
164 | + /** |
|
165 | + * @param Collection $resources |
|
166 | + */ |
|
164 | 167 | public function assertCheckedResources($resources) |
165 | 168 | { |
166 | 169 | $healthCount = $resources->reduce(function ($carry, $item) { |
@@ -164,13 +164,13 @@ discard block |
||
164 | 164 | |
165 | 165 | public function assertCheckedResources($resources) |
166 | 166 | { |
167 | - $healthCount = $resources->reduce(function ($carry, $item) { |
|
167 | + $healthCount = $resources->reduce(function($carry, $item) { |
|
168 | 168 | return $carry + (isset($item['health']['healthy']) ? 1 : 0); |
169 | 169 | }, 0); |
170 | 170 | |
171 | 171 | $this->assertEquals(count(static::ALL_RESOURCES), $healthCount); |
172 | 172 | |
173 | - $failing = $resources->filter(function ($item) { |
|
173 | + $failing = $resources->filter(function($item) { |
|
174 | 174 | return $item['health']['healthy']; |
175 | 175 | }); |
176 | 176 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | ->toArray(), |
213 | 213 | $this->getResources() |
214 | 214 | ->keys() |
215 | - ->map(function ($value) { |
|
215 | + ->map(function($value) { |
|
216 | 216 | return strtolower($value); |
217 | 217 | }) |
218 | 218 | ->sort() |
@@ -247,17 +247,17 @@ discard block |
||
247 | 247 | $string = $controller->string()->getContent(); |
248 | 248 | |
249 | 249 | $this->assertTrue( |
250 | - strpos($string, config('health.string.ok') . '-') !== false |
|
250 | + strpos($string, config('health.string.ok').'-') !== false |
|
251 | 251 | ); |
252 | 252 | |
253 | 253 | $this->assertTrue( |
254 | - strpos($string, config('health.string.fail') . '-') !== false |
|
254 | + strpos($string, config('health.string.fail').'-') !== false |
|
255 | 255 | ); |
256 | 256 | |
257 | 257 | $this->assertTrue( |
258 | 258 | strpos( |
259 | 259 | $controller->panel()->getContent(), |
260 | - '<title>' . config('health.title') . '</title>' |
|
260 | + '<title>'.config('health.title').'</title>' |
|
261 | 261 | ) !== false |
262 | 262 | ); |
263 | 263 | } |
@@ -25,9 +25,9 @@ |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
28 | - * @param $name |
|
29 | - * @param $content |
|
30 | - * @param null $folder |
|
28 | + * @param string $name |
|
29 | + * @param string $content |
|
30 | + * @param string $folder |
|
31 | 31 | * @return string |
32 | 32 | */ |
33 | 33 | private function temporaryFile($name, $content, $folder = null) |
@@ -47,7 +47,7 @@ |
||
47 | 47 | |
48 | 48 | file_put_contents($file, $content); |
49 | 49 | |
50 | - register_shutdown_function(function () use ($file) { |
|
50 | + register_shutdown_function(function() use ($file) { |
|
51 | 51 | if (file_exists($file)) { |
52 | 52 | unlink($file); |
53 | 53 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * Convert uptime to seconds. |
140 | 140 | * |
141 | 141 | * @param $date |
142 | - * @return int |
|
142 | + * @return double |
|
143 | 143 | */ |
144 | 144 | protected function uptimeInSeconds($date) |
145 | 145 | { |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * Make uptime message. |
153 | 153 | * |
154 | 154 | * @param $current |
155 | - * @param $saved |
|
155 | + * @param \Illuminate\Support\Collection $saved |
|
156 | 156 | * @return string |
157 | 157 | */ |
158 | 158 | protected function makeMessage($current, $saved = null) |
@@ -68,10 +68,10 @@ |
||
68 | 68 | protected function normalizeMatches($matches) |
69 | 69 | { |
70 | 70 | return collect($matches) |
71 | - ->filter(function ($item, $key) { |
|
71 | + ->filter(function($item, $key) { |
|
72 | 72 | return !is_numeric($key); |
73 | 73 | }) |
74 | - ->map(function ($item, $key) { |
|
74 | + ->map(function($item, $key) { |
|
75 | 75 | $return = $item[0]; |
76 | 76 | |
77 | 77 | if (starts_with($key, 'load')) { |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * Convert uptime to seconds. |
140 | 140 | * |
141 | 141 | * @param $date |
142 | - * @return int |
|
142 | + * @return double |
|
143 | 143 | */ |
144 | 144 | protected function uptimeInSeconds($date) |
145 | 145 | { |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * Make uptime message. |
153 | 153 | * |
154 | 154 | * @param $current |
155 | - * @param $saved |
|
155 | + * @param \Illuminate\Support\Collection $saved |
|
156 | 156 | * @return string |
157 | 157 | */ |
158 | 158 | protected function makeMessage($current, $saved = null) |
@@ -68,10 +68,10 @@ |
||
68 | 68 | protected function normalizeMatches($matches) |
69 | 69 | { |
70 | 70 | return collect($matches) |
71 | - ->filter(function ($item, $key) { |
|
71 | + ->filter(function($item, $key) { |
|
72 | 72 | return !is_numeric($key); |
73 | 73 | }) |
74 | - ->map(function ($item, $key) { |
|
74 | + ->map(function($item, $key) { |
|
75 | 75 | $return = $item[0]; |
76 | 76 | |
77 | 77 | if (starts_with($key, 'load')) { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * Check if string is absolute path. |
58 | 58 | * |
59 | 59 | * @param $path |
60 | - * @return string |
|
60 | + * @return boolean |
|
61 | 61 | */ |
62 | 62 | function is_absolute_path($path) |
63 | 63 | { |
@@ -84,6 +84,7 @@ discard block |
||
84 | 84 | /** |
85 | 85 | * Convert bytes to human readable. |
86 | 86 | * |
87 | + * @param double $bytes |
|
87 | 88 | * @return string |
88 | 89 | */ |
89 | 90 | function bytes_to_human($bytes) |
@@ -102,7 +103,7 @@ discard block |
||
102 | 103 | /** |
103 | 104 | * Convert bytes to human readable. |
104 | 105 | * |
105 | - * @return string |
|
106 | + * @return double |
|
106 | 107 | */ |
107 | 108 | function human_to_bytes($str) |
108 | 109 | { |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | function package_resources_dir() |
46 | 46 | { |
47 | 47 | return ( |
48 | - package_dir() . |
|
49 | - DIRECTORY_SEPARATOR . |
|
50 | - 'config' . |
|
51 | - DIRECTORY_SEPARATOR . |
|
48 | + package_dir(). |
|
49 | + DIRECTORY_SEPARATOR. |
|
50 | + 'config'. |
|
51 | + DIRECTORY_SEPARATOR. |
|
52 | 52 | 'resources' |
53 | 53 | ); |
54 | 54 | } |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | // Optional wrapper(s). |
67 | 67 | $regExp = |
68 | 68 | // Optional root prefix. |
69 | - '%^(?<wrappers>(?:[[:print:]]{2,}://)*)' . |
|
70 | - '(?<root>(?:[[:alpha:]]:/|/)?)' . |
|
69 | + '%^(?<wrappers>(?:[[:print:]]{2,}://)*)'. |
|
70 | + '(?<root>(?:[[:alpha:]]:/|/)?)'. |
|
71 | 71 | // Actual path. |
72 | 72 | '(?<path>(?:[[:print:]]*))$%'; |
73 | 73 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | $f_base = floor($base); |
99 | 99 | |
100 | - return round(pow(1024, $base - floor($base)), 1) . $suffix[$f_base]; |
|
100 | + return round(pow(1024, $base - floor($base)), 1).$suffix[$f_base]; |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 |
@@ -41,7 +41,7 @@ |
||
41 | 41 | |
42 | 42 | private function getChecker() |
43 | 43 | { |
44 | - return function () { |
|
44 | + return function() { |
|
45 | 45 | return 'DUMMY DATA'; |
46 | 46 | }; |
47 | 47 | } |