Conditions | 11 |
Paths | 256 |
Total Lines | 107 |
Code Lines | 56 |
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 |
||
50 | public function fire() |
||
51 | { |
||
52 | $presenter = $this->option('presenter'); |
||
53 | if (is_null($presenter) |
||
|
|||
54 | && $this->confirm('Would you like to create a Presenter? [y|N]') |
||
55 | ) { |
||
56 | $presenter = 'yes'; |
||
57 | } |
||
58 | |||
59 | if ($presenter == 'yes') { |
||
60 | $this->call( |
||
61 | 'yl:presenter', |
||
62 | [ |
||
63 | 'name' => $this->argument('name'), |
||
64 | '--force' => $this->option('force'), |
||
65 | ] |
||
66 | ); |
||
67 | } |
||
68 | |||
69 | $validator = $this->option('validator'); |
||
70 | if (is_null($validator) |
||
71 | && $this->confirm('Would you like to create a Validator? [y|N]') |
||
72 | ) { |
||
73 | $validator = 'yes'; |
||
74 | } |
||
75 | |||
76 | if ($validator == 'yes') { |
||
77 | $this->call( |
||
78 | 'yl:validator', |
||
79 | [ |
||
80 | 'name' => $this->argument('name'), |
||
81 | '--rules' => $this->option('rules'), |
||
82 | '--force' => $this->option('force'), |
||
83 | ] |
||
84 | ); |
||
85 | } |
||
86 | |||
87 | if ($this->confirm('Would you like to create a Controller? [y|N]')) { |
||
88 | |||
89 | // Generate a controller resource |
||
90 | $this->call( |
||
91 | 'yl:controller', |
||
92 | [ |
||
93 | 'name' => $this->argument('name'), |
||
94 | '--fields' => $this->option('fields'), |
||
95 | '--force' => $this->option('force'), |
||
96 | ] |
||
97 | ); |
||
98 | } |
||
99 | |||
100 | if ($this->confirm('Would you like to create a API Controller? [y|N]')) { |
||
101 | |||
102 | // Generate a api controller resource |
||
103 | $this->call( |
||
104 | 'yl:api_controller', |
||
105 | [ |
||
106 | 'name' => $this->argument('name'), |
||
107 | '--fields' => $this->option('fields'), |
||
108 | '--force' => $this->option('force'), |
||
109 | ] |
||
110 | ); |
||
111 | } |
||
112 | |||
113 | if ($this->confirm('Would you like to create CURD views? [y|N]')) { |
||
114 | |||
115 | // Generate a controller resource |
||
116 | $this->call( |
||
117 | 'yl:views', |
||
118 | [ |
||
119 | 'name' => $this->argument('name'), |
||
120 | '--fields' => $this->option('fields'), |
||
121 | '--force' => $this->option('force'), |
||
122 | ] |
||
123 | ); |
||
124 | } |
||
125 | |||
126 | if ($this->confirm('Would you like to create language package? [y|N]')) { |
||
127 | |||
128 | // Generate a controller resource |
||
129 | $this->call( |
||
130 | 'yl:lang', |
||
131 | [ |
||
132 | 'name' => $this->argument('name'), |
||
133 | '--fields' => $this->option('fields'), |
||
134 | '--force' => $this->option('force'), |
||
135 | ] |
||
136 | ); |
||
137 | } |
||
138 | |||
139 | $this->call( |
||
140 | 'yl:repository', |
||
141 | [ |
||
142 | 'name' => $this->argument('name'), |
||
143 | '--fillable' => $this->option('fillable'), |
||
144 | '--rules' => $this->option('rules'), |
||
145 | '--fields' => $this->option('fields'), |
||
146 | '--validator' => $validator, |
||
147 | '--presenter' => $presenter, |
||
148 | '--force' => $this->option('force'), |
||
149 | ] |
||
150 | ); |
||
151 | |||
152 | $this->call( |
||
153 | 'yl:bindings', |
||
154 | [ |
||
155 | 'name' => $this->argument('name'), |
||
156 | '--force' => $this->option('force'), |
||
157 | ] |
||
224 |