| Conditions | 10 | 
| Paths | 8 | 
| Total Lines | 48 | 
| Code Lines | 26 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 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 | ||
| 157 | public function handle() | ||
| 158 |     { | ||
| 159 |         if ($this->isReservedName($this->getNameInput())) { | ||
| 160 |             $this->components->error('The name "'.$this->getNameInput().'" is reserved by PHP.'); | ||
| 161 | |||
| 162 | return false; | ||
| 163 | } | ||
| 164 | |||
| 165 |         if (!$this->option('model')) { | ||
| 166 |             if (!$this->option('interface')) { | ||
| 167 |                 $this->components->error('Expected options "model" and "interface"!'); | ||
| 168 | return false; | ||
| 169 | } | ||
| 170 | |||
| 171 |             $this->components->error('Expected option "model"!'); | ||
| 172 | return false; | ||
| 173 | } | ||
| 174 | |||
| 175 |         if (!$this->option('interface')) { | ||
| 176 |             $this->components->error('Expected option "interface"!'); | ||
| 177 | return false; | ||
| 178 | } | ||
| 179 | |||
| 180 | $name = $this->qualifyClass($this->getNameInput()); | ||
| 181 | |||
| 182 | $path = $this->getPath($name); | ||
| 183 | |||
| 184 |         if ((! $this->hasOption('force') || | ||
| 185 |              ! $this->option('force')) && | ||
| 186 |              $this->alreadyExists($this->getNameInput())) { | ||
| 187 | $this->components->error($this->type.' already exists.'); | ||
| 188 | |||
| 189 | return false; | ||
| 190 | } | ||
| 191 | |||
| 192 | $this->makeDirectory($path); | ||
| 193 | |||
| 194 | $this->files->put($path, $this->sortImports($this->buildClass($name))); | ||
| 195 | |||
| 196 | $info = $this->type; | ||
| 197 | |||
| 198 |         if (in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { | ||
| 199 |             if ($this->handleTestCreation($path)) { | ||
| 200 | $info .= ' and test'; | ||
| 201 | } | ||
| 202 | } | ||
| 203 | |||
| 204 |         $this->components->info(sprintf('%s [%s] created successfully.', $info, $path)); | ||
| 205 | } | ||
| 207 |