Conditions | 10 |
Paths | 10 |
Total Lines | 21 |
Code Lines | 18 |
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 |
||
42 | public function __invoke(LogEvent $event): void |
||
43 | { |
||
44 | switch ($event->getSeverity()) { |
||
45 | case LogLevel::EMERGENCY: |
||
46 | case LogLevel::ALERT: |
||
47 | case LogLevel::CRITICAL: |
||
48 | case LogLevel::ERROR: |
||
49 | $this->output->writeln("<error>ERROR: {$event->getMessage()}</error>"); |
||
50 | break; |
||
51 | case LogLevel::WARNING: |
||
52 | $this->output->writeln("<question>WARNING: {$event->getMessage()}</question>"); |
||
53 | break; |
||
54 | case LogLevel::NOTICE: |
||
55 | case LogLevel::INFO: |
||
56 | $this->output->writeln($event->getMessage()); |
||
57 | break; |
||
58 | case LogLevel::DEBUG: |
||
59 | if ($this->output->isVerbose()) { |
||
60 | $this->output->writeln($event->getMessage()); |
||
61 | } |
||
62 | break; |
||
63 | } |
||
66 |