Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
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 |
||
30 | public function serviceProvider() |
||
31 | { |
||
32 | $wildcardId = 42; |
||
33 | $sourceUrl = '/cms'; |
||
34 | $destinationUrl = '/cxm'; |
||
35 | $forward = true; |
||
36 | $wildcard = new URLWildcard( |
||
37 | array( |
||
38 | 'id' => $wildcardId, |
||
39 | 'sourceUrl' => $sourceUrl, |
||
40 | 'destinationUrl' => $destinationUrl, |
||
41 | 'forward' => $forward, |
||
42 | ) |
||
43 | ); |
||
44 | |||
45 | return array( |
||
46 | array( |
||
47 | 'create', |
||
48 | array($sourceUrl, $destinationUrl, $forward), |
||
49 | $wildcard, |
||
50 | 1, |
||
51 | URLWildcardServiceSignals\CreateSignal::class, |
||
52 | array('urlWildcardId' => $wildcardId), |
||
53 | ), |
||
54 | array( |
||
55 | 'remove', |
||
56 | array($wildcard), |
||
57 | null, |
||
58 | 1, |
||
59 | URLWildcardServiceSignals\RemoveSignal::class, |
||
60 | array('urlWildcardId' => $wildcardId), |
||
61 | ), |
||
62 | array( |
||
63 | 'load', |
||
64 | array($wildcardId), |
||
65 | $wildcard, |
||
66 | 0, |
||
67 | ), |
||
68 | array( |
||
69 | 'loadAll', |
||
70 | array(0, 1), |
||
71 | array($wildcard), |
||
72 | 0, |
||
73 | ), |
||
74 | array( |
||
75 | 'translate', |
||
76 | array($sourceUrl), |
||
77 | new URLWildcardTranslationResult( |
||
78 | array( |
||
79 | 'uri' => $destinationUrl, |
||
80 | 'forward' => $forward, |
||
81 | ) |
||
82 | ), |
||
83 | 1, |
||
84 | URLWildcardServiceSignals\TranslateSignal::class, |
||
85 | array('url' => $sourceUrl), |
||
86 | ), |
||
87 | ); |
||
88 | } |
||
89 | } |
||
90 |