Conditions | 12 |
Paths | 10 |
Total Lines | 27 |
Code Lines | 23 |
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 |
||
36 | $this->dispatcher = $dispatcher; |
||
37 | } |
||
38 | |||
39 | public function getCompleters(Project $project, Context $context) |
||
40 | { |
||
41 | $completers = []; |
||
42 | foreach($this->completers as $completer) { |
||
43 | if ($completer->canHandle($project, $context)) { |
||
44 | $completers[] = $completer; |
||
45 | } |
||
46 | } |
||
47 | $event = new CustomCompleterEvent($project, $context); |
||
48 | $this->dispatcher->dispatch(self::CUSTOM_COMPLETER, $event); |
||
49 | if ($event->completer instanceof CompleterInterface) { |
||
50 | $completers[] = $event->completer; |
||
51 | } |
||
52 | return $completers; |
||
53 | } |
||
54 | |||
55 | private $completers; |
||
56 | private $dispatcher; |
||
57 | } |
||
58 |