Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 35 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | 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 |
||
107 | public function testLanguageSwitchLinks() { |
||
108 | // TODO: Check cache metadata. |
||
109 | $metadata = $this->defaultCacheMetaData(); |
||
110 | $metadata->addCacheContexts(['languages:language_url']); |
||
111 | |||
112 | $this->assertResults($this->getQueryFromFile('language_switch_links.gql'), [], [ |
||
113 | 'route' => [ |
||
114 | 'links' => [ |
||
115 | 0 => [ |
||
116 | 'language' => [ |
||
117 | 'id' => 'en', |
||
118 | ], |
||
119 | 'url' => [ |
||
120 | 'path' => '/en', |
||
121 | ], |
||
122 | 'title' => 'English', |
||
123 | 'active' => TRUE, |
||
124 | ], |
||
125 | 1 => [ |
||
126 | 'language' => [ |
||
127 | 'id' => 'fr', |
||
128 | ], |
||
129 | 'url' => [ |
||
130 | 'path' => '/fr', |
||
131 | ], |
||
132 | 'title' => NULL, |
||
133 | 'active' => FALSE, |
||
134 | ], |
||
135 | 2 => [ |
||
136 | 'language' => [ |
||
137 | 'id' => 'es', |
||
138 | ], |
||
139 | 'url' => [ |
||
140 | 'path' => '/es', |
||
141 | ], |
||
142 | 'title' => NULL, |
||
143 | 'active' => FALSE, |
||
144 | ], |
||
145 | 3 => [ |
||
146 | 'language' => [ |
||
147 | 'id' => 'pt-br', |
||
148 | ], |
||
149 | 'url' => [ |
||
150 | 'path' => '/', |
||
151 | ], |
||
152 | 'title' => NULL, |
||
153 | 'active' => FALSE, |
||
154 | ], |
||
155 | ], |
||
156 | ], |
||
157 | ], $metadata); |
||
158 | } |
||
159 | } |
||
160 |