Conditions | 13 |
Paths | 43 |
Total Lines | 66 |
Code Lines | 42 |
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 |
||
121 | $svrConf['swoole']['document_root'] = $svrConf['laravel_base_path'] . '/public'; |
||
122 | } |
||
123 | if ($this->option('daemonize')) { |
||
124 | $svrConf['swoole']['daemonize'] = true; |
||
125 | } |
||
126 | if (empty($svrConf['swoole']['pid_file'])) { |
||
127 | $svrConf['swoole']['pid_file'] = storage_path('laravels.pid'); |
||
128 | } |
||
129 | return 0; |
||
130 | } |
||
131 | |||
132 | protected function preCheck(array $svrConf) |
||
133 | { |
||
134 | if (!empty($svrConf['enable_gzip']) && version_compare(swoole_version(), '4.1.0', '>=')) { |
||
135 | $this->error('enable_gzip is DEPRECATED since Swoole 4.1.0, set http_compression of Swoole instead, http_compression is disabled by default.'); |
||
136 | $this->info('If there is a proxy server like Nginx, suggest that enable gzip in Nginx and disable gzip in Swoole, to avoid the repeated gzip compression for response.'); |
||
137 | return 1; |
||
138 | } |
||
139 | if (!empty($svrConf['events'])) { |
||
140 | if (empty($svrConf['swoole']['task_worker_num']) || $svrConf['swoole']['task_worker_num'] <= 0) { |
||
141 | $this->error('Asynchronous event listening needs to set task_worker_num > 0'); |
||
142 | return 1; |
||
143 | } |
||
144 | } |
||
145 | return 0; |
||
146 | } |
||
147 | |||
148 | |||
149 | public function publish() |
||
150 | { |
||
151 | $basePath = config('laravels.laravel_base_path') ?: base_path(); |
||
152 | $configPath = $basePath . '/config/laravels.php'; |
||
153 | $todoList = [ |
||
154 | ['from' => __DIR__ . '/../../config/laravels.php', 'to' => $configPath, 'mode' => 0644], |
||
155 | ['from' => __DIR__ . '/../../bin/laravels', 'to' => $basePath . '/bin/laravels', 'mode' => 0755], |
||
156 | ['from' => __DIR__ . '/../../bin/fswatch', 'to' => $basePath . '/bin/fswatch', 'mode' => 0755], |
||
157 | ]; |
||
158 | if (file_exists($configPath)) { |
||
159 | $choice = $this->anticipate($configPath . ' already exists, do you want to override it ? Y/N', |
||
160 | ['Y', 'N'], |
||
161 | 'N' |
||
162 | ); |
||
163 | if (!$choice || strtoupper($choice) !== 'Y') { |
||
164 | array_shift($todoList); |
||
165 | } |
||
166 | } |
||
167 | |||
168 | /** |
||
169 | * @var Filesystem $files |
||
170 | */ |
||
171 | $files = app(Filesystem::class); |
||
172 | foreach ($todoList as $todo) { |
||
173 | $toDir = dirname($todo['to']); |
||
174 | if (!$files->isDirectory($toDir)) { |
||
175 | $files->makeDirectory($toDir, 0755, true); |
||
176 | } |
||
177 | $files->copy($todo['from'], $todo['to']); |
||
178 | chmod($todo['to'], $todo['mode']); |
||
179 | $from = str_replace($basePath, '', realpath($todo['from'])); |
||
180 | $to = str_replace($basePath, '', realpath($todo['to'])); |
||
181 | $this->line('<info>Copied File</info> <comment>[' . $from . ']</comment> <info>To</info> <comment>[' . $to . ']</comment>'); |
||
182 | } |
||
183 | return 0; |
||
184 | } |
||
185 | |||
186 | public function info($string) |
||
187 | { |
||
204 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.