| Conditions | 9 |
| Paths | 128 |
| Total Lines | 65 |
| Code Lines | 38 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 38 | public static function environment() |
||
| 39 | { |
||
| 40 | $envs=[ |
||
| 41 | ['name' => __('admin.home.envs.php'), 'value' => 'PHP/'.PHP_VERSION], |
||
| 42 | ['name' => __('admin.home.envs.laravel'), 'value' => app()->version()], |
||
|
|
|||
| 43 | ['name' => __('admin.home.envs.cgi'), 'value' => php_sapi_name()], |
||
| 44 | ['name' => __('admin.home.envs.uname'), 'value' => php_uname()], |
||
| 45 | ['name' => __('admin.home.envs.server'), 'value' => Arr::get($_SERVER, 'SERVER_SOFTWARE')], |
||
| 46 | |||
| 47 | ['name' => __('admin.home.envs.cache'), 'value' => config('cache.default')], |
||
| 48 | ['name' => __('admin.home.envs.session'), 'value' => config('session.driver')], |
||
| 49 | ['name' => __('admin.home.envs.queue'), 'value' => config('queue.default')], |
||
| 50 | |||
| 51 | ['name' => __('admin.home.envs.timezone'), 'value' => config('app.timezone')], |
||
| 52 | ['name' => __('admin.home.envs.locale'), 'value' => config('app.locale')], |
||
| 53 | ['name' => __('admin.home.envs.env'), 'value' => config('app.env')], |
||
| 54 | ['name' => __('admin.home.envs.url'), 'value' => config('app.url')], |
||
| 55 | |||
| 56 | ['name' => __('admin.home.envs.tlsv13'), 'value' => ["Not Supported", "Supported"][in_array("tlsv1.3", stream_get_transports())]], |
||
| 57 | ]; |
||
| 58 | |||
| 59 | foreach ($envs as &$env) { |
||
| 60 | $env['icon']="check-circle"; |
||
| 61 | $env['color']="wemd-teal-text"; |
||
| 62 | } |
||
| 63 | |||
| 64 | // PHP Version Check |
||
| 65 | $installedVersion=new Version(PHP_VERSION); |
||
| 66 | $requireVersion=new Version("7.4.0"); |
||
| 67 | if (!($installedVersion->isGreaterThan($requireVersion) || $installedVersion->getVersionString()===$requireVersion->getVersionString())) { |
||
| 68 | $envs[0]['icon']="close-circle"; |
||
| 69 | $envs[0]['color']="wemd-pink-text"; |
||
| 70 | } |
||
| 71 | |||
| 72 | // Cache Driver Check |
||
| 73 | if (config('cache.default')!="redis") { |
||
| 74 | $envs[5]['icon']="close-circle"; |
||
| 75 | $envs[5]['color']="wemd-pink-text"; |
||
| 76 | } |
||
| 77 | |||
| 78 | // Session Driver Check |
||
| 79 | if (config('session.driver')!="redis") { |
||
| 80 | $envs[6]['icon']="close-circle"; |
||
| 81 | $envs[6]['color']="wemd-pink-text"; |
||
| 82 | } |
||
| 83 | |||
| 84 | // Queue Driver Check |
||
| 85 | if (config('queue.default')!="database") { |
||
| 86 | $envs[7]['icon']="close-circle"; |
||
| 87 | $envs[7]['color']="wemd-pink-text"; |
||
| 88 | } |
||
| 89 | |||
| 90 | // Locale Check |
||
| 91 | if (!in_array(strtolower(config('app.locale')), ['en', 'zh-cn'])) { |
||
| 92 | $envs[9]['icon']="close-circle"; |
||
| 93 | $envs[9]['color']="wemd-pink-text"; |
||
| 94 | } |
||
| 95 | |||
| 96 | // TLSv1.3 Check |
||
| 97 | if ($envs[12]['value']=="Not Supported") { |
||
| 98 | $envs[12]['icon']="close-circle"; |
||
| 99 | $envs[12]['color']="wemd-pink-text"; |
||
| 100 | } |
||
| 101 | |||
| 102 | return view('admin::dashboard.environment', compact('envs')); |
||
| 103 | } |
||
| 105 |