Conditions | 4 |
Paths | 1 |
Total Lines | 53 |
Code Lines | 30 |
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 |
||
147 | private function compileCss($projectDir) |
||
148 | { |
||
149 | $this->output->writeln('Generating stylesheets'); |
||
150 | |||
151 | $applicationScssPath = $projectDir . '/theme/frontend/scss/'; |
||
152 | |||
153 | $scss = new Compiler(); |
||
154 | $scss->setIgnoreErrors(true); |
||
155 | $scss->addImportPath($applicationScssPath); |
||
156 | $scss->addImportPath(function ($path) use ($projectDir) { |
||
|
|||
157 | //Check for tilde as this refers to the node_modules dir |
||
158 | if (strpos($path, '~') === 0) { |
||
159 | $path = str_replace( |
||
160 | ['~', 'bootstrap'], |
||
161 | [$projectDir . '/vendor/', 'twbs/bootstrap'], |
||
162 | $path |
||
163 | ); |
||
164 | |||
165 | $path .= '.scss'; |
||
166 | |||
167 | //if file does not exist, try with underscore before filename |
||
168 | if (!file_exists($path)) { |
||
169 | $chunks = explode('/', $path); |
||
170 | |||
171 | end($chunks); |
||
172 | $lastKey = key($chunks); |
||
173 | reset($chunks); |
||
174 | |||
175 | $chunks[$lastKey] = '_' . $chunks[$lastKey]; |
||
176 | |||
177 | $path = implode('/', $chunks); |
||
178 | } |
||
179 | |||
180 | if (!file_exists($path)) { |
||
181 | return null; |
||
182 | } |
||
183 | } |
||
184 | |||
185 | return $path; |
||
186 | }); |
||
187 | |||
188 | file_put_contents( |
||
189 | $projectDir . '/web/assets/css/style.min.css', |
||
190 | $scss->compile(file_get_contents($applicationScssPath . '/all.scss')) |
||
191 | ); |
||
192 | |||
193 | file_put_contents( |
||
194 | $projectDir . '/web/assets/css/legacy.min.css', |
||
195 | $scss->compile(file_get_contents($applicationScssPath . '/legacy.scss')) |
||
196 | ); |
||
197 | |||
198 | $this->output->writeln('<info>- Stylesheets generated</info>'); |
||
199 | } |
||
200 | |||
217 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: