@@ -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) |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | storage_path() |
| 19 | 19 | ); |
| 20 | 20 | |
| 21 | - if (! file_exists($file)) { |
|
| 21 | + if (!file_exists($file)) { |
|
| 22 | 22 | return $this->makeResult( |
| 23 | 23 | false, |
| 24 | 24 | sprintf($this->target->getErrorMessage(), $file) |
@@ -47,7 +47,7 @@ discard block |
||
| 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) |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | ($ss = $this->uptimeInSeconds($this->database)); |
| 26 | 26 | |
| 27 | 27 | return $this->makeResult( |
| 28 | - ! $rebooted, |
|
| 28 | + !$rebooted, |
|
| 29 | 29 | $this->makeMessage($current, $this->database) |
| 30 | 30 | ); |
| 31 | 31 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | throw new DomainException((string) $error); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - return (! is_array($system_string) || empty($system_string)) |
|
| 47 | + return (!is_array($system_string) || empty($system_string)) |
|
| 48 | 48 | ? '' |
| 49 | 49 | : $system_string[0]; |
| 50 | 50 | } |
@@ -69,10 +69,10 @@ discard block |
||
| 69 | 69 | protected function normalizeMatches($matches) |
| 70 | 70 | { |
| 71 | 71 | return collect($matches) |
| 72 | - ->filter(function ($item, $key) { |
|
| 73 | - return ! is_numeric($key); |
|
| 72 | + ->filter(function($item, $key) { |
|
| 73 | + return !is_numeric($key); |
|
| 74 | 74 | }) |
| 75 | - ->map(function ($item, $key) { |
|
| 75 | + ->map(function($item, $key) { |
|
| 76 | 76 | $return = $item[0]; |
| 77 | 77 | |
| 78 | 78 | if (Str::startsWith($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) |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | ($ss = $this->uptimeInSeconds($this->database)); |
| 26 | 26 | |
| 27 | 27 | return $this->makeResult( |
| 28 | - ! $rebooted, |
|
| 28 | + !$rebooted, |
|
| 29 | 29 | $this->makeMessage($current, $this->database) |
| 30 | 30 | ); |
| 31 | 31 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | throw new DomainException((string) $error); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - return (! is_array($system_string) || empty($system_string)) |
|
| 47 | + return (!is_array($system_string) || empty($system_string)) |
|
| 48 | 48 | ? '' |
| 49 | 49 | : $system_string[0]; |
| 50 | 50 | } |
@@ -69,10 +69,10 @@ discard block |
||
| 69 | 69 | protected function normalizeMatches($matches) |
| 70 | 70 | { |
| 71 | 71 | return collect($matches) |
| 72 | - ->filter(function ($item, $key) { |
|
| 73 | - return ! is_numeric($key); |
|
| 72 | + ->filter(function($item, $key) { |
|
| 73 | + return !is_numeric($key); |
|
| 74 | 74 | }) |
| 75 | - ->map(function ($item, $key) { |
|
| 75 | + ->map(function($item, $key) { |
|
| 76 | 76 | $return = $item[0]; |
| 77 | 77 | |
| 78 | 78 | if (Str::startsWith($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 | { |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | use PragmaRX\Health\Service; |
| 4 | 4 | |
| 5 | -if (! function_exists('instantiate')) { |
|
| 5 | +if (!function_exists('instantiate')) { |
|
| 6 | 6 | /** |
| 7 | 7 | * Instantiate a class. |
| 8 | 8 | * |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | } |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -if (! function_exists('package_dir')) { |
|
| 25 | +if (!function_exists('package_dir')) { |
|
| 26 | 26 | /** |
| 27 | 27 | * Get the package root directory. |
| 28 | 28 | * |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | -if (! function_exists('package_resources_dir')) { |
|
| 39 | +if (!function_exists('package_resources_dir')) { |
|
| 40 | 40 | /** |
| 41 | 41 | * Get package resources directory. |
| 42 | 42 | * |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | -if (! function_exists('is_absolute_path')) { |
|
| 55 | +if (!function_exists('is_absolute_path')) { |
|
| 56 | 56 | /** |
| 57 | 57 | * Check if string is absolute path. |
| 58 | 58 | * |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | -if (! function_exists('bytes_to_human')) { |
|
| 83 | +if (!function_exists('bytes_to_human')) { |
|
| 84 | 84 | /** |
| 85 | 85 | * Convert bytes to human readable. |
| 86 | 86 | * |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | -if (! function_exists('human_to_bytes')) { |
|
| 101 | +if (!function_exists('human_to_bytes')) { |
|
| 102 | 102 | /** |
| 103 | 103 | * Convert bytes to human readable. |
| 104 | 104 | * |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | -if (! function_exists('ip_address_from_hostname')) { |
|
| 129 | +if (!function_exists('ip_address_from_hostname')) { |
|
| 130 | 130 | function ip_address_from_hostname($host) |
| 131 | 131 | { |
| 132 | 132 | if ( |
@@ -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 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * @param $hostname |
| 29 | - * @return mixed |
|
| 29 | + * @return string |
|
| 30 | 30 | */ |
| 31 | 31 | protected function hosnameAndIp($hostname, $ipAdress) |
| 32 | 32 | { |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | ' -n 1 -i '. |
| 91 | 91 | $ttl. |
| 92 | 92 | ' -w '. |
| 93 | - $timeout * 1000 . |
|
| 93 | + $timeout * 1000. |
|
| 94 | 94 | ' '. |
| 95 | 95 | $host; |
| 96 | 96 | } elseif (strtoupper(PHP_OS) === 'DARWIN') { |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $output = array_values(array_filter($output)); |
| 127 | 127 | |
| 128 | 128 | // If the result line in the output is not empty, parse it. |
| 129 | - if (! empty($output[1])) { |
|
| 129 | + if (!empty($output[1])) { |
|
| 130 | 130 | // Search for a 'time' value in the result line. |
| 131 | 131 | $response = preg_match( |
| 132 | 132 | "/time(?:=|<)(?<time>[\.0-9]+)(?:|\s)ms/", |
@@ -30,6 +30,9 @@ |
||
| 30 | 30 | return $this->makeHealthyResult(); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | + /** |
|
| 34 | + * @param double $free |
|
| 35 | + */ |
|
| 33 | 36 | public function isEnough($free, $minimum) |
| 34 | 37 | { |
| 35 | 38 | return $free > human_to_bytes($minimum); |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | { |
| 16 | 16 | $free = disk_free_space($this->target->path); |
| 17 | 17 | |
| 18 | - if (! $this->isEnough($free, $this->target->minimum)) { |
|
| 18 | + if (!$this->isEnough($free, $this->target->minimum)) { |
|
| 19 | 19 | return $this->makeResult( |
| 20 | 20 | false, |
| 21 | 21 | sprintf( |
@@ -28,7 +28,8 @@ |
||
| 28 | 28 | * Get hostname and IP. |
| 29 | 29 | * |
| 30 | 30 | * @param $hostname |
| 31 | - * @return mixed |
|
| 31 | + * @param boolean $ipAdress |
|
| 32 | + * @return string |
|
| 32 | 33 | */ |
| 33 | 34 | protected function hosnameAndIp($hostname, $ipAdress) |
| 34 | 35 | { |
@@ -74,7 +74,7 @@ |
||
| 74 | 74 | */ |
| 75 | 75 | protected function portIsNotConnectable($ipAddress) |
| 76 | 76 | { |
| 77 | - return ! $this->portCheck( |
|
| 77 | + return !$this->portCheck( |
|
| 78 | 78 | $ipAddress, |
| 79 | 79 | $this->target->port, |
| 80 | 80 | $this->target->timeout ?? 1 |
@@ -27,12 +27,18 @@ discard block |
||
| 27 | 27 | return $this->makeHealthyResult(); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | + /** |
|
| 31 | + * @param integer|null $processes |
|
| 32 | + */ |
|
| 30 | 33 | private function checkMinMax($processes) |
| 31 | 34 | { |
| 32 | 35 | return $this->buildMessage('minimum', $processes) |
| 33 | 36 | ?: $this->buildMessage('maximum', $processes); |
| 34 | 37 | } |
| 35 | 38 | |
| 39 | + /** |
|
| 40 | + * @param string $type |
|
| 41 | + */ |
|
| 36 | 42 | private function buildMessage($type, $processes) |
| 37 | 43 | { |
| 38 | 44 | $instances = $this->target->instances; |
@@ -75,7 +81,7 @@ discard block |
||
| 75 | 81 | |
| 76 | 82 | /** |
| 77 | 83 | * @param $file |
| 78 | - * @return bool |
|
| 84 | + * @return integer |
|
| 79 | 85 | */ |
| 80 | 86 | private function checkPidFileExistence($file) |
| 81 | 87 | { |
@@ -90,7 +96,7 @@ discard block |
||
| 90 | 96 | |
| 91 | 97 | /** |
| 92 | 98 | * @param $file |
| 93 | - * @return bool |
|
| 99 | + * @return boolean|null |
|
| 94 | 100 | */ |
| 95 | 101 | private function checkPidFileLockState($file) |
| 96 | 102 | { |
@@ -112,7 +118,7 @@ discard block |
||
| 112 | 118 | } |
| 113 | 119 | |
| 114 | 120 | /** |
| 115 | - * @return bool |
|
| 121 | + * @return integer |
|
| 116 | 122 | */ |
| 117 | 123 | private function processPidFileIsLocked() |
| 118 | 124 | { |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | $message = $this->checkMinMax($this->getProcessesRunningCount()); |
| 22 | 22 | |
| 23 | - if (! empty($message)) { |
|
| 23 | + if (!empty($message)) { |
|
| 24 | 24 | return $this->makeResult(false, $message); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | $instances = $this->target->instances; |
| 39 | 39 | |
| 40 | - if (! $count = (int) $instances[$type]['count']) { |
|
| 40 | + if (!$count = (int) $instances[$type]['count']) { |
|
| 41 | 41 | return ''; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | fclose($filePointer); |
| 103 | 103 | |
| 104 | - if (! $locked) { |
|
| 104 | + if (!$locked) { |
|
| 105 | 105 | throw new DomainException( |
| 106 | 106 | sprintf($this->target->pid_file_missing_not_locked, $file) |
| 107 | 107 | ); |