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