| Conditions | 1 |
| Paths | 1 |
| Total Lines | 54 |
| Code Lines | 34 |
| 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 |
||
| 17 | public function testLanguageSwitchLinks() { |
||
| 18 | // TODO: Check cache metadata. |
||
| 19 | $metadata = $this->defaultCacheMetaData(); |
||
| 20 | |||
| 21 | $english = [ |
||
| 22 | 'language' => [ |
||
| 23 | 'id' => 'en', |
||
| 24 | ], |
||
| 25 | 'url' => [ |
||
| 26 | 'path' => '/en', |
||
| 27 | ], |
||
| 28 | 'title' => 'English', |
||
| 29 | 'active' => true, |
||
| 30 | ]; |
||
| 31 | |||
| 32 | $french = [ |
||
| 33 | 'language' => [ |
||
| 34 | 'id' => 'fr', |
||
| 35 | ], |
||
| 36 | 'url' => [ |
||
| 37 | 'path' => '/fr', |
||
| 38 | ], |
||
| 39 | 'title' => NULL, |
||
| 40 | 'active' => false, |
||
| 41 | ]; |
||
| 42 | |||
| 43 | $spanish = [ |
||
| 44 | 'language' => [ |
||
| 45 | 'id' => 'es', |
||
| 46 | ], |
||
| 47 | 'url' => [ |
||
| 48 | 'path' => '/es', |
||
| 49 | ], |
||
| 50 | 'title' => NULL, |
||
| 51 | 'active' => false, |
||
| 52 | ]; |
||
| 53 | |||
| 54 | $brazil = [ |
||
| 55 | 'language' => [ |
||
| 56 | 'id' => 'pt-br', |
||
| 57 | ], |
||
| 58 | 'url' => [ |
||
| 59 | 'path' => '/', |
||
| 60 | ], |
||
| 61 | 'title' => NULL, |
||
| 62 | 'active' => false, |
||
| 63 | ]; |
||
| 64 | |||
| 65 | $this->assertResults($this->getQueryFromFile('language_switch_links.gql'), [], [ |
||
| 66 | 'route' => [ |
||
| 67 | 'links' => [$english, $french, $spanish, $brazil], |
||
| 68 | ], |
||
| 69 | ], $metadata); |
||
| 70 | } |
||
| 71 | |||
| 73 |