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 |
||
128 | private function compileCss($projectDir) |
||
129 | { |
||
130 | $this->output->writeln('Generating stylesheets'); |
||
131 | |||
132 | $applicationScssPath = $projectDir . '/app/Resources/assets/scss/'; |
||
133 | |||
134 | $scss = new Compiler(); |
||
135 | $scss->setIgnoreErrors(true); |
||
136 | $scss->addImportPath($applicationScssPath); |
||
137 | $scss->addImportPath(function ($path) use ($projectDir) { |
||
|
|||
138 | //Check for tilde as this refers to the node_modules dir |
||
139 | if (strpos($path, '~') === 0) { |
||
140 | $path = str_replace( |
||
141 | ['~', 'bootstrap'], |
||
142 | [$projectDir . '/vendor/', 'twbs/bootstrap'], |
||
143 | $path |
||
144 | ); |
||
145 | |||
146 | $path .= '.scss'; |
||
147 | |||
148 | //if file does not exist, try with underscore before filename |
||
149 | if (!file_exists($path)) { |
||
150 | $chunks = explode('/', $path); |
||
151 | |||
152 | end($chunks); |
||
153 | $lastKey = key($chunks); |
||
154 | reset($chunks); |
||
155 | |||
156 | $chunks[$lastKey] = '_' . $chunks[$lastKey]; |
||
157 | |||
158 | $path = implode('/', $chunks); |
||
159 | } |
||
160 | |||
161 | if (!file_exists($path)) { |
||
162 | return null; |
||
163 | } |
||
164 | } |
||
165 | |||
166 | return $path; |
||
167 | }); |
||
168 | |||
169 | file_put_contents( |
||
170 | $projectDir . '/web/assets/css/style.min.css', |
||
171 | $scss->compile(file_get_contents($applicationScssPath . '/all.scss')) |
||
172 | ); |
||
173 | |||
174 | file_put_contents( |
||
175 | $projectDir . '/web/assets/css/legacy.min.css', |
||
176 | $scss->compile(file_get_contents($applicationScssPath . '/legacy.scss')) |
||
177 | ); |
||
178 | |||
179 | $this->output->writeln('- Stylesheets generated'); |
||
180 | } |
||
181 | } |
||
182 |
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: