| Conditions | 12 |
| Paths | 10 |
| Total Lines | 22 |
| Code Lines | 19 |
| 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 |
||
| 75 | public function prepareRuleMatcher(IRuleMatcher $ruleMatcher, string $eventName, GenericEvent $event): void { |
||
| 76 | switch ($eventName) { |
||
| 77 | case 'postCreate': |
||
| 78 | case 'postWrite': |
||
| 79 | case 'postDelete': |
||
| 80 | case 'postTouch': |
||
| 81 | $ruleMatcher->setEntitySubject($this, $event->getSubject()); |
||
| 82 | break; |
||
| 83 | case 'postRename': |
||
| 84 | case 'postCopy': |
||
| 85 | $ruleMatcher->setEntitySubject($this, $event->getSubject()[1]); |
||
| 86 | break; |
||
| 87 | case MapperEvent::EVENT_ASSIGN: |
||
| 88 | if(!$event instanceof MapperEvent || $event->getObjectType() !== 'files') { |
||
|
|
|||
| 89 | break; |
||
| 90 | } |
||
| 91 | $nodes = $this->root->getById((int)$event->getObjectId()); |
||
| 92 | if(is_array($nodes) && !empty($nodes)) { |
||
| 93 | $node = array_shift($nodes); |
||
| 94 | $ruleMatcher->setEntitySubject($this, $node); |
||
| 95 | } |
||
| 96 | break; |
||
| 97 | } |
||
| 100 |