| Conditions | 1 |
| Paths | 1 |
| Total Lines | 107 |
| Code Lines | 52 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 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 |
||
| 221 | public function testXml2arrayWithCVCrossRef() { |
||
| 222 | $CV = <<<XML |
||
| 223 | <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> |
||
| 224 | <root> |
||
| 225 | <langs> |
||
| 226 | <lang id="en">English</lang> |
||
| 227 | <lang id="fr">Français</lang> |
||
| 228 | </langs> |
||
| 229 | <curriculumVitae> |
||
| 230 | <lookingFor> |
||
| 231 | <experience crossref="curriculumVitae/experiences/items/experience[@id='SecondJob']"></experience> |
||
| 232 | <presentation lang="en">A good presentation.</presentation> |
||
| 233 | <presentation lang="fr">Une bonne présentation.</presentation> |
||
| 234 | </lookingFor> |
||
| 235 | <experiences anchor="experiences"> |
||
| 236 | <anchorTitle lang="en">Experiences</anchorTitle> |
||
| 237 | <anchorTitle lang="fr">Expériences Professionnelles</anchorTitle> |
||
| 238 | <items> |
||
| 239 | <experience id="SecondJob"> |
||
| 240 | <date lang="en">Apr 2011 - Present</date> |
||
| 241 | <date lang="fr">Avr. 2011 - Aujourd'hui</date> |
||
| 242 | <job lang="en">Second Job</job> |
||
| 243 | <job lang="fr">Deuxième Job</job> |
||
| 244 | <society crossref="societies/society[@ref='OneSociety']"></society> |
||
| 245 | <missions lang="en"> |
||
| 246 | <item>A item.</item> |
||
| 247 | </missions> |
||
| 248 | <missions lang="fr"> |
||
| 249 | <item>Un item.</item> |
||
| 250 | </missions> |
||
| 251 | </experience> |
||
| 252 | <experience id="FirstJob"> |
||
| 253 | <date lang="en">Nov 2009 - Apr 2011</date> |
||
| 254 | <date lang="fr">Nov. 2009 - Avr. 2011</date> |
||
| 255 | <job lang="en">First Job</job> |
||
| 256 | <job lang="fr">Premier Job</job> |
||
| 257 | <society crossref="societies/society[@ref='OneSociety']"></society> |
||
| 258 | <missions lang="en"> |
||
| 259 | <item>A item.</item> |
||
| 260 | </missions> |
||
| 261 | <missions lang="fr"> |
||
| 262 | <item>Un item.</item> |
||
| 263 | </missions> |
||
| 264 | </experience> |
||
| 265 | </items> |
||
| 266 | </experiences> |
||
| 267 | </curriculumVitae> |
||
| 268 | <societies> |
||
| 269 | <society ref="OneSociety"> |
||
| 270 | <name>OneSociety</name> |
||
| 271 | <address>address</address> |
||
| 272 | <siteurl>http://www.google.com</siteurl> |
||
| 273 | </society> |
||
| 274 | </societies> |
||
| 275 | </root> |
||
| 276 | XML; |
||
| 277 | $expected = array( |
||
| 278 | 'langs' => array( |
||
| 279 | 'en' => "English", |
||
| 280 | 'fr' => "Français"), |
||
| 281 | 'curriculumVitae' => array( |
||
| 282 | 'lookingFor' => array( |
||
| 283 | 'experience' => array( |
||
| 284 | 'job' => "Second Job", |
||
| 285 | 'date' => "Apr 2011 - Present", |
||
| 286 | 'society' => array( |
||
| 287 | 'name' => "OneSociety", |
||
| 288 | 'address' => "address", |
||
| 289 | 'siteurl' => "http://www.google.com", |
||
| 290 | 'society' => array('ref' => "OneSociety")), |
||
| 291 | 'missions' => array( |
||
| 292 | 'item' => array("A item."))), |
||
| 293 | 'presentation' => "A good presentation."), |
||
| 294 | 'experiences' => array( |
||
| 295 | 'anchorTitle' => "Experiences", |
||
| 296 | 'items' => array( |
||
| 297 | 'SecondJob' => array( |
||
| 298 | 'job' => "Second Job", |
||
| 299 | 'date' => "Apr 2011 - Present", |
||
| 300 | 'society' => array( |
||
| 301 | 'name' => "OneSociety", |
||
| 302 | 'address' => "address", |
||
| 303 | 'siteurl' => "http://www.google.com", |
||
| 304 | 'society' => array('ref' => "OneSociety")), |
||
| 305 | 'missions' => array( |
||
| 306 | 'item' => array("A item."))), |
||
| 307 | 'FirstJob' => array( |
||
| 308 | 'job' => "First Job", |
||
| 309 | 'date' => "Nov 2009 - Apr 2011", |
||
| 310 | 'society' => array( |
||
| 311 | 'name' => "OneSociety", |
||
| 312 | 'address' => "address", |
||
| 313 | 'siteurl' => "http://www.google.com", |
||
| 314 | 'society' => array('ref' => "OneSociety")), |
||
| 315 | 'missions' => array( |
||
| 316 | 'item' => array("A item.")))), |
||
| 317 | 'anchor' => "experiences")), |
||
| 318 | 'societies' => array( |
||
| 319 | 'society' => array( |
||
| 320 | 'name' => "OneSociety", |
||
| 321 | 'address' => "address", |
||
| 322 | 'siteurl' => "http://www.google.com", |
||
| 323 | 'ref' => "OneSociety")) |
||
| 324 | ); |
||
| 325 | |||
| 326 | $this->assertXml2Array($expected, $CV, $CV); |
||
| 327 | } |
||
| 328 | |||
| 336 |
This check marks private properties in classes that are never used. Those properties can be removed.