Conditions | 1 |
Paths | 1 |
Total Lines | 111 |
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 |
||
132 | public function testFromApiWithSingleSet(): void |
||
133 | { |
||
134 | $data = <<<'EOD' |
||
135 | { |
||
136 | "id" : "63de4613", |
||
137 | "versionId" : "7be1aaa0", |
||
138 | "eventDate" : "23-08-1964", |
||
139 | "lastUpdated" : "2013-10-20T05:18:08.000+0000", |
||
140 | "artist" : { |
||
141 | "mbid" : "b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d", |
||
142 | "tmid" : 735610, |
||
143 | "name" : "The Beatles", |
||
144 | "sortName" : "Beatles, The", |
||
145 | "disambiguation" : "", |
||
146 | "url" : "https://www.setlist.fm/setlists/the-beatles-23d6a88b.html" |
||
147 | }, |
||
148 | "venue" : { |
||
149 | "id" : "33d62cf9", |
||
150 | "name" : "Hollywood Bowl", |
||
151 | "city" : { |
||
152 | "id" : "5368361", |
||
153 | "name" : "Los Angeles", |
||
154 | "state" : "California", |
||
155 | "stateCode" : "CA", |
||
156 | "coords" : { |
||
157 | "lat" : 34.052, |
||
158 | "long" : -118.244 |
||
159 | }, |
||
160 | "country" : { |
||
161 | "code" : "US", |
||
162 | "name" : "United States" |
||
163 | } |
||
164 | }, |
||
165 | "url" : "https://www.setlist.fm/venue/hollywood-bowl-los-angeles-ca-usa-33d62cf9.html" |
||
166 | }, |
||
167 | "tour" : { |
||
168 | "name" : "North American Tour 1964" |
||
169 | }, |
||
170 | "set" : [ { |
||
171 | "song" : [ { |
||
172 | "name" : "Twist and Shout", |
||
173 | "cover" : { |
||
174 | "mbid" : "f18eac60-48d2-4d2b-b432-e43ce7e31d36", |
||
175 | "name" : "The Top Notes", |
||
176 | "sortName" : "Top Notes, The", |
||
177 | "url" : "https://www.setlist.fm/setlists/the-top-notes-53d433dd.html" |
||
178 | } |
||
179 | }, { |
||
180 | "name" : "You Can't Do That" |
||
181 | }, { |
||
182 | "name" : "All My Loving" |
||
183 | }, { |
||
184 | "name" : "She Loves You" |
||
185 | }, { |
||
186 | "name" : "Things We Said Today" |
||
187 | }, { |
||
188 | "name" : "Roll Over Beethoven", |
||
189 | "cover" : { |
||
190 | "mbid" : "592a3b6d-c42b-4567-99c9-ecf63bd66499", |
||
191 | "tmid" : 734540, |
||
192 | "name" : "Chuck Berry", |
||
193 | "sortName" : "Berry, Chuck", |
||
194 | "disambiguation" : "", |
||
195 | "url" : "https://www.setlist.fm/setlists/chuck-berry-63d6a2b7.html" |
||
196 | } |
||
197 | }, { |
||
198 | "name" : "Can't Buy Me Love" |
||
199 | }, { |
||
200 | "name" : "If I Fell" |
||
201 | }, { |
||
202 | "name" : "I Want to Hold Your Hand" |
||
203 | }, { |
||
204 | "name" : "Boys", |
||
205 | "cover" : { |
||
206 | "mbid" : "a8540ea0-1a74-4c22-8b70-1348a77a74a0", |
||
207 | "name" : "The Shirelles", |
||
208 | "sortName" : "Shirelles, The", |
||
209 | "disambiguation" : "", |
||
210 | "url" : "https://www.setlist.fm/setlists/the-shirelles-bd69d7a.html" |
||
211 | } |
||
212 | }, { |
||
213 | "name" : "A Hard Day's Night" |
||
214 | }, { |
||
215 | "name" : "Long Tall Sally", |
||
216 | "cover" : { |
||
217 | "mbid" : "95c2339b-8277-49a6-9aaf-08d8eeeaa0be", |
||
218 | "tmid" : 735520, |
||
219 | "name" : "Little Richard", |
||
220 | "sortName" : "Little Richard", |
||
221 | "disambiguation" : "", |
||
222 | "url" : "https://www.setlist.fm/setlists/little-richard-4bd6af2e.html" |
||
223 | } |
||
224 | } ] |
||
225 | } ], |
||
226 | "info" : "Recorded and published as 'The Beatles at the Hollywood Bowl'", |
||
227 | "url" : "https://www.setlist.fm/setlist/the-beatles/1964/hollywood-bowl-los-angeles-ca-63de4613.html" |
||
228 | } |
||
229 | EOD; |
||
230 | |||
231 | $setlist = Setlist::fromApi(json_decode($data, true)); |
||
232 | $this->assertSame('63de4613', $setlist->getId()); |
||
233 | $this->assertSame('7be1aaa0', $setlist->getVersionId()); |
||
234 | $this->assertNotNull($setlist->getVenue()); |
||
235 | $this->assertNotNull($setlist->getArtist()); |
||
236 | $this->assertEquals(new DateTime('23-08-1964'), $setlist->getEventDate(), '', 0); |
||
237 | $this->assertSame('Recorded and published as \'The Beatles at the Hollywood Bowl\'', $setlist->getInfo()); |
||
238 | $this->assertNotNull($setlist->getSets()); |
||
239 | $this->assertNotNull($setlist->getTour()); |
||
240 | $this->assertEquals(new DateTime('2013-10-20T05:18:08.000+0000'), $setlist->getUpdateDate(), '', 0); |
||
241 | $this->assertSame('https://www.setlist.fm/setlist/the-beatles/1964/hollywood-bowl-los-angeles-ca-63de4613.html', $setlist->getUrl()); |
||
242 | } |
||
243 | } |
||
244 |