Conditions | 7 |
Paths | 24 |
Total Lines | 57 |
Code Lines | 38 |
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 |
||
53 | public function fire() |
||
54 | { |
||
55 | $domain = $this->getDomainNameForRepo(); |
||
56 | $domainPath = $this->laravel['domains']->getDomainPath($domain); |
||
57 | |||
58 | if ($this->confirm('Would you like to create a Presenter? [y|N]')) { |
||
59 | $this->call('domain:presenter', [ |
||
60 | 'name' => $this->argument('name'), |
||
61 | '--force' => $this->option('force'), |
||
62 | 'domain' => $domain, |
||
63 | 'domain-path' => $domainPath |
||
64 | ]); |
||
65 | } |
||
66 | |||
67 | $validator = $this->option('validator'); |
||
68 | if (is_null($validator) && $this->confirm('Would you like to create a Validator? [y|N]')) { |
||
69 | $validator = 'yes'; |
||
70 | } |
||
71 | |||
72 | if ($validator == 'yes') { |
||
73 | $this->call('domain:validator', [ |
||
74 | 'name' => $this->argument('name'), |
||
75 | '--rules' => $this->option('rules'), |
||
76 | '--force' => $this->option('force'), |
||
77 | 'domain' => $domain, |
||
78 | 'domain-path' => $domainPath |
||
79 | ]); |
||
80 | } |
||
81 | |||
82 | if ($this->confirm('Would you like to create a Controller? [y|N]')) { |
||
83 | |||
84 | $resource_args = [ |
||
85 | 'name' => $this->argument('name'), |
||
86 | 'domain' => $domain, |
||
87 | 'domain-path' => $domainPath |
||
88 | ]; |
||
89 | |||
90 | // Generate a controller resource |
||
91 | $controller_command = ((float) app()->version() >= 5.5 ? 'make:rest-controller' : 'make:resource'); |
||
|
|||
92 | $this->call($controller_command, $resource_args); |
||
93 | } |
||
94 | |||
95 | $this->call('domain:repository', [ |
||
96 | 'name' => $this->argument('name'), |
||
97 | '--fillable' => $this->option('fillable'), |
||
98 | '--rules' => $this->option('rules'), |
||
99 | '--validator' => $validator, |
||
100 | '--force' => $this->option('force'), |
||
101 | 'domain' => $domain, |
||
102 | 'domain-path' => $domainPath |
||
103 | ]); |
||
104 | |||
105 | $this->call('domain:repo-bindings', [ |
||
106 | 'name' => $this->argument('name'), |
||
107 | '--force' => $this->option('force'), |
||
108 | 'domain' => $domain, |
||
109 | 'domain-path' => $domainPath |
||
110 | ]); |
||
171 |