Conditions | 1 |
Paths | 1 |
Total Lines | 112 |
Code Lines | 78 |
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 |
||
115 | public function titleProvider() { |
||
116 | |||
117 | $title = $this->getMockBuilder( '\Title' ) |
||
118 | ->disableOriginalConstructor() |
||
119 | ->getMock(); |
||
120 | |||
121 | $title->expects( $this->any() ) |
||
122 | ->method( 'getDBKey' ) |
||
123 | ->will( $this->returnValue( 'Foo' ) ); |
||
124 | |||
125 | $title->expects( $this->any() ) |
||
126 | ->method( 'getNamespace' ) |
||
127 | ->will( $this->returnValue( 0 ) ); |
||
128 | |||
129 | $title->expects( $this->any() ) |
||
130 | ->method( 'isProtected' ) |
||
131 | ->with( $this->equalTo( 'edit' ) ) |
||
132 | ->will( $this->returnValue( true ) ); |
||
133 | |||
134 | $title->expects( $this->any() ) |
||
135 | ->method( 'getRestrictions' ) |
||
136 | ->will( $this->returnValue( array() ) ); |
||
137 | |||
138 | $provider = array(); |
||
139 | |||
140 | #0 no EditProtectionRight |
||
141 | $provider[] = array( |
||
142 | $title, |
||
143 | false, |
||
144 | array( |
||
145 | 'propertyCount' => 0, |
||
146 | 'propertyKeys' => array(), |
||
147 | 'propertyValues' => array(), |
||
148 | ) |
||
149 | ); |
||
150 | |||
151 | #1 |
||
152 | $provider[] = array( |
||
153 | $title, |
||
154 | 'Foo', |
||
155 | array( |
||
156 | 'propertyCount' => 0, |
||
157 | 'propertyKeys' => array(), |
||
158 | 'propertyValues' => array(), |
||
159 | ) |
||
160 | ); |
||
161 | |||
162 | $title = $this->getMockBuilder( '\Title' ) |
||
163 | ->disableOriginalConstructor() |
||
164 | ->getMock(); |
||
165 | |||
166 | $title->expects( $this->any() ) |
||
167 | ->method( 'getDBKey' ) |
||
168 | ->will( $this->returnValue( 'Foo' ) ); |
||
169 | |||
170 | $title->expects( $this->any() ) |
||
171 | ->method( 'getNamespace' ) |
||
172 | ->will( $this->returnValue( 0 ) ); |
||
173 | |||
174 | $title->expects( $this->any() ) |
||
175 | ->method( 'isProtected' ) |
||
176 | ->with( $this->equalTo( 'edit' ) ) |
||
177 | ->will( $this->returnValue( true ) ); |
||
178 | |||
179 | $title->expects( $this->any() ) |
||
180 | ->method( 'getRestrictions' ) |
||
181 | ->will( $this->returnValue( array( 'Foo' ) ) ); |
||
182 | |||
183 | #2 |
||
184 | $provider[] = array( |
||
185 | $title, |
||
186 | 'Foo', |
||
187 | array( |
||
188 | 'propertyCount' => 1, |
||
189 | 'propertyKeys' => array( '_EDIP' ), |
||
190 | 'propertyValues' => array( true ), |
||
191 | ) |
||
192 | ); |
||
193 | |||
194 | $title = $this->getMockBuilder( '\Title' ) |
||
195 | ->disableOriginalConstructor() |
||
196 | ->getMock(); |
||
197 | |||
198 | $title->expects( $this->any() ) |
||
199 | ->method( 'getDBKey' ) |
||
200 | ->will( $this->returnValue( 'Foo' ) ); |
||
201 | |||
202 | $title->expects( $this->any() ) |
||
203 | ->method( 'getNamespace' ) |
||
204 | ->will( $this->returnValue( 0 ) ); |
||
205 | |||
206 | $title->expects( $this->any() ) |
||
207 | ->method( 'isProtected' ) |
||
208 | ->with( $this->equalTo( 'edit' ) ) |
||
209 | ->will( $this->returnValue( false ) ); |
||
210 | |||
211 | $title->expects( $this->never() ) |
||
212 | ->method( 'getRestrictions' ); |
||
213 | |||
214 | #3 |
||
215 | $provider[] = array( |
||
216 | $title, |
||
217 | 'Foo', |
||
218 | array( |
||
219 | 'propertyCount' => 0, |
||
220 | 'propertyKeys' => array(), |
||
221 | 'propertyValues' => array(), |
||
222 | ) |
||
223 | ); |
||
224 | |||
225 | return $provider; |
||
226 | } |
||
227 | |||
229 |