Conditions | 1 |
Paths | 1 |
Total Lines | 63 |
Code Lines | 41 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
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 |
||
129 | public function provideConflictDetection() { |
||
130 | $cases = array(); |
||
131 | |||
132 | // #0: adding a label where there was none before |
||
133 | $base = self::newEntity( Item::ENTITY_TYPE ); |
||
134 | $current = unserialize( serialize( $base ) ); |
||
135 | |||
136 | $new = unserialize( serialize( $base ) ); |
||
137 | $new->setLabel( 'en', 'TEST' ); |
||
138 | |||
139 | $cases[] = array( |
||
140 | $base, |
||
141 | $current, |
||
142 | $new, |
||
143 | 0 // there should eb no conflicts. |
||
144 | ); |
||
145 | |||
146 | // #1: adding an alias where there was none before |
||
147 | $base = self::newEntity( Item::ENTITY_TYPE ); |
||
148 | $current = $base; |
||
149 | |||
150 | $new = unserialize( serialize( $base ) ); |
||
151 | $new->setAliases( 'en', array( 'TEST' ) ); |
||
152 | |||
153 | $cases[] = array( |
||
154 | $base, |
||
155 | $current, |
||
156 | $new, |
||
157 | 0 // there should eb no conflicts. |
||
158 | ); |
||
159 | |||
160 | // #2: adding an alias where there already was one before |
||
161 | $base = self::newEntity( Item::ENTITY_TYPE ); |
||
162 | $base->setAliases( 'en', array( 'Foo' ) ); |
||
163 | $current = $base; |
||
164 | |||
165 | $new = unserialize( serialize( $base ) ); |
||
166 | $new->setAliases( 'en', array( 'Bar' ) ); |
||
167 | |||
168 | $cases[] = array( |
||
169 | $base, |
||
170 | $current, |
||
171 | $new, |
||
172 | 0 // there should be no conflicts. |
||
173 | ); |
||
174 | |||
175 | // #3: adding an alias where there already was one in another language |
||
176 | $base = self::newEntity( Item::ENTITY_TYPE ); |
||
177 | $base->setAliases( 'en', array( 'Foo' ) ); |
||
178 | $current = $base; |
||
179 | |||
180 | $new = unserialize( serialize( $base ) ); |
||
181 | $new->setAliases( 'de', array( 'Bar' ) ); |
||
182 | |||
183 | $cases[] = array( |
||
184 | $base, |
||
185 | $current, |
||
186 | $new, |
||
187 | 0 // there should be no conflicts. |
||
188 | ); |
||
189 | |||
190 | return $cases; |
||
191 | } |
||
192 | |||
218 |