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