Conditions | 9 |
Paths | 128 |
Total Lines | 66 |
Code Lines | 39 |
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 | ['name' => __('admin.home.envs.babelMirror'), 'value' => config('babel.mirror')], |
||
56 | |||
57 | ['name' => __('admin.home.envs.tlsv13'), 'value' => ["Not Supported", "Supported"][in_array("tlsv1.3", stream_get_transports())]], |
||
58 | ]; |
||
59 | |||
60 | foreach ($envs as &$env) { |
||
61 | $env['icon']="check-circle"; |
||
62 | $env['color']="wemd-teal-text"; |
||
63 | } |
||
64 | |||
65 | // PHP Version Check |
||
66 | $installedVersion=new Version(PHP_VERSION); |
||
67 | $requireVersion=new Version("7.4.0"); |
||
68 | if (!($installedVersion->isGreaterThan($requireVersion) || $installedVersion->getVersionString()===$requireVersion->getVersionString())) { |
||
69 | $envs[0]['icon']="close-circle"; |
||
70 | $envs[0]['color']="wemd-pink-text"; |
||
71 | } |
||
72 | |||
73 | // Cache Driver Check |
||
74 | if (config('cache.default')!="redis") { |
||
75 | $envs[5]['icon']="close-circle"; |
||
76 | $envs[5]['color']="wemd-pink-text"; |
||
77 | } |
||
78 | |||
79 | // Session Driver Check |
||
80 | if (config('session.driver')!="redis") { |
||
81 | $envs[6]['icon']="close-circle"; |
||
82 | $envs[6]['color']="wemd-pink-text"; |
||
83 | } |
||
84 | |||
85 | // Queue Driver Check |
||
86 | if (config('queue.default')!="database") { |
||
87 | $envs[7]['icon']="close-circle"; |
||
88 | $envs[7]['color']="wemd-pink-text"; |
||
89 | } |
||
90 | |||
91 | // Locale Check |
||
92 | if (!in_array(strtolower(config('app.locale')), ['en', 'zh-cn'])) { |
||
93 | $envs[9]['icon']="close-circle"; |
||
94 | $envs[9]['color']="wemd-pink-text"; |
||
95 | } |
||
96 | |||
97 | // TLSv1.3 Check |
||
98 | if ($envs[12]['value']=="Not Supported") { |
||
99 | $envs[12]['icon']="close-circle"; |
||
100 | $envs[12]['color']="wemd-pink-text"; |
||
101 | } |
||
102 | |||
103 | return view('admin::dashboard.environment', compact('envs')); |
||
104 | } |
||
106 |