Conditions | 1 |
Paths | 1 |
Total Lines | 98 |
Code Lines | 54 |
Lines | 88 |
Ratio | 89.8 % |
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 namespace Comodojo\Extender; |
||
146 | protected function pushScheduleCommands() { |
||
147 | |||
148 | $this->getSocket()->getCommands() |
||
149 | ->add('scheduler:refresh', function($data, $daemon) { |
||
150 | |||
151 | return $this->getWorkers()->get("scheduler")->getOutputChannel()->send('refresh'); |
||
152 | |||
153 | }) |
||
154 | View Code Duplication | ->add('scheduler:add', function(Schedule $data, $daemon) { |
|
155 | |||
156 | $manager = new ScheduleManager( |
||
157 | $this->getConfiguration(), |
||
158 | $this->getLogger(), |
||
159 | $this->getEvents(), |
||
160 | $this->getEntityManager() |
||
161 | ); |
||
162 | |||
163 | $id = $manager->add($data); |
||
164 | |||
165 | $this->getWorkers()->get("scheduler")->getOutputChannel()->send('refresh'); |
||
166 | |||
167 | return $id; |
||
168 | |||
169 | }) |
||
170 | View Code Duplication | ->add('scheduler:get', function($id, $daemon) { |
|
171 | |||
172 | $manager = new ScheduleManager( |
||
173 | $this->getConfiguration(), |
||
174 | $this->getLogger(), |
||
175 | $this->getEvents(), |
||
176 | $this->getEntityManager() |
||
177 | ); |
||
178 | |||
179 | return $manager->get($id); |
||
180 | |||
181 | }) |
||
182 | View Code Duplication | ->add('scheduler:getByName', function($name, $daemon) { |
|
183 | |||
184 | $manager = new ScheduleManager( |
||
185 | $this->getConfiguration(), |
||
186 | $this->getLogger(), |
||
187 | $this->getEvents(), |
||
188 | $this->getEntityManager() |
||
189 | ); |
||
190 | |||
191 | return $manager->getByName($name); |
||
192 | |||
193 | }) |
||
194 | View Code Duplication | ->add('scheduler:edit', function(Schedule $data, $daemon) { |
|
195 | |||
196 | $manager = new ScheduleManager( |
||
197 | $this->getConfiguration(), |
||
198 | $this->getLogger(), |
||
199 | $this->getEvents(), |
||
200 | $this->getEntityManager() |
||
201 | ); |
||
202 | |||
203 | $edit = $manager->edit($data); |
||
204 | |||
205 | $this->getWorkers()->get("scheduler")->getOutputChannel()->send('refresh'); |
||
206 | |||
207 | return $edit; |
||
208 | |||
209 | }) |
||
210 | View Code Duplication | ->add('scheduler:enable', function($name, $daemon) { |
|
211 | |||
212 | $manager = new ScheduleManager( |
||
213 | $this->getConfiguration(), |
||
214 | $this->getLogger(), |
||
215 | $this->getEvents(), |
||
216 | $this->getEntityManager() |
||
217 | ); |
||
218 | |||
219 | $edit = $manager->enable($name); |
||
220 | |||
221 | $this->getWorkers()->get("scheduler")->getOutputChannel()->send('refresh'); |
||
222 | |||
223 | return $edit; |
||
224 | |||
225 | }) |
||
226 | View Code Duplication | ->add('scheduler:edit', function($name, $daemon) { |
|
227 | |||
228 | $manager = new ScheduleManager( |
||
229 | $this->getConfiguration(), |
||
230 | $this->getLogger(), |
||
231 | $this->getEvents(), |
||
232 | $this->getEntityManager() |
||
233 | ); |
||
234 | |||
235 | $edit = $manager->disable($name); |
||
236 | |||
237 | $this->getWorkers()->get("scheduler")->getOutputChannel()->send('refresh'); |
||
238 | |||
239 | return $edit; |
||
240 | |||
241 | }); |
||
242 | |||
243 | } |
||
244 | |||
250 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.