Conditions | 1 |
Paths | 1 |
Total Lines | 118 |
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 |
||
32 | public function serviceProvider() |
||
33 | { |
||
34 | $sectionId = 1; |
||
35 | $sectionIdentifier = 'mordor'; |
||
36 | $sectionName = 'Mordor'; |
||
37 | $locationId = 46; |
||
38 | $contentId = 42; |
||
39 | |||
40 | $section = new Section( |
||
41 | array( |
||
42 | 'id' => $sectionId, |
||
43 | 'identifier' => $sectionIdentifier, |
||
44 | 'name' => $sectionName, |
||
45 | ) |
||
46 | ); |
||
47 | |||
48 | $location = new Location([ |
||
49 | 'id' => $locationId, |
||
50 | ]); |
||
51 | |||
52 | $contentInfo = $this->getContentInfo($contentId, md5('Osgiliath')); |
||
53 | |||
54 | $sectionCreateStruct = new SectionCreateStruct(); |
||
55 | $sectionUpdateStruct = new SectionUpdateStruct(); |
||
56 | |||
57 | return array( |
||
58 | array( |
||
59 | 'createSection', |
||
60 | array($sectionCreateStruct), |
||
61 | $section, |
||
62 | 1, |
||
63 | SectionServiceSignal\CreateSectionSignal::class, |
||
64 | array('sectionId' => $sectionId), |
||
65 | ), |
||
66 | array( |
||
67 | 'updateSection', |
||
68 | array($section, $sectionUpdateStruct), |
||
69 | $section, |
||
70 | 1, |
||
71 | SectionServiceSignal\UpdateSectionSignal::class, |
||
72 | array('sectionId' => $sectionId), |
||
73 | ), |
||
74 | array( |
||
75 | 'loadSection', |
||
76 | array($sectionId), |
||
77 | $section, |
||
78 | 0, |
||
79 | ), |
||
80 | array( |
||
81 | 'loadSections', |
||
82 | array(), |
||
83 | array($section), |
||
84 | 0, |
||
85 | ), |
||
86 | array( |
||
87 | 'loadSectionByIdentifier', |
||
88 | array($sectionIdentifier), |
||
89 | $section, |
||
90 | 0, |
||
91 | ), |
||
92 | array( |
||
93 | 'countAssignedContents', |
||
94 | array($section), |
||
95 | 42, |
||
96 | 0, |
||
97 | ), |
||
98 | array( |
||
99 | 'isSectionUsed', |
||
100 | array($section), |
||
101 | true, |
||
102 | 0, |
||
103 | ), |
||
104 | array( |
||
105 | 'assignSection', |
||
106 | array($contentInfo, $section), |
||
107 | null, |
||
108 | 1, |
||
109 | SectionServiceSignal\AssignSectionSignal::class, |
||
110 | array( |
||
111 | 'contentId' => $contentId, |
||
112 | 'sectionId' => $sectionId, |
||
113 | ), |
||
114 | ), |
||
115 | array( |
||
116 | 'assignSectionToSubtree', |
||
117 | array($location, $section), |
||
118 | null, |
||
119 | 1, |
||
120 | SectionServiceSignal\AssignSectionToSubtreeSignal::class, |
||
121 | array( |
||
122 | 'locationId' => $locationId, |
||
123 | 'sectionId' => $sectionId, |
||
124 | ), |
||
125 | ), |
||
126 | array( |
||
127 | 'deleteSection', |
||
128 | array($section), |
||
129 | null, |
||
130 | 1, |
||
131 | SectionServiceSignal\DeleteSectionSignal::class, |
||
132 | array( |
||
133 | 'sectionId' => $sectionId, |
||
134 | ), |
||
135 | ), |
||
136 | array( |
||
137 | 'newSectionCreateStruct', |
||
138 | array(), |
||
139 | $sectionCreateStruct, |
||
140 | 0, |
||
141 | ), |
||
142 | array( |
||
143 | 'newSectionUpdateStruct', |
||
144 | array(), |
||
145 | $sectionUpdateStruct, |
||
146 | 0, |
||
147 | ), |
||
148 | ); |
||
149 | } |
||
150 | } |
||
151 |