Conditions | 15 |
Paths | 15 |
Total Lines | 35 |
Lines | 0 |
Ratio | 0 % |
Tests | 31 |
CRAP Score | 15 |
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 |
||
17 | 15 | public function map(string $type) |
|
18 | { |
||
19 | 15 | switch ($type) { |
|
20 | 15 | case 'line': |
|
21 | 1 | return LineFormatterFactory::class; |
|
22 | 14 | case 'html': |
|
23 | 1 | return HtmlFormatterFactory::class; |
|
24 | 13 | case 'normalizer': |
|
25 | 1 | return NormalizerFormatterFactory::class; |
|
26 | 12 | case 'scalar': |
|
27 | 1 | return ScalarFormatterFactory::class; |
|
28 | 11 | case 'json': |
|
29 | 1 | return JsonFormatterFactory::class; |
|
30 | 10 | case 'wildfire': |
|
31 | 1 | return WildfireFormatterFactory::class; |
|
32 | 9 | case 'chromePHP': |
|
33 | 1 | return ChromePHPFormatterFactory::class; |
|
34 | 8 | case 'gelf': |
|
35 | 1 | return GelfMessageFormatterFactory::class; |
|
36 | 7 | case 'logstash': |
|
37 | 1 | return LogstashFormatterFactory::class; |
|
38 | 6 | case 'elastica': |
|
39 | 1 | return ElasticaFormatterFactory::class; |
|
40 | 5 | case 'loggly': |
|
41 | 1 | return LogglyFormatterFactory::class; |
|
42 | 4 | case 'flowdock': |
|
43 | 1 | return FlowdockFormatterFactory::class; |
|
44 | 3 | case 'mongodb': |
|
45 | 1 | return MongoDBFormatterFactory::class; |
|
46 | 2 | case 'logmatic': |
|
47 | 1 | return LogmaticFormatterFactory::class; |
|
48 | } |
||
49 | |||
50 | 1 | return null; |
|
51 | } |
||
52 | } |
||
53 |