| Conditions | 1 |
| Paths | 1 |
| Total Lines | 164 |
| 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 |
||
| 245 | public function testGetCardTransitions() |
||
| 246 | { |
||
| 247 | $client = $this->prophesize(TrelloApiClient::class); |
||
| 248 | |||
| 249 | $id = '5cdfb33499236c320e7d772c'; |
||
| 250 | |||
| 251 | $creationCard = [ |
||
| 252 | 0 => [ |
||
| 253 | 'id' => $id, |
||
| 254 | 'idMemberCreator' => '521dbcdd68ba6dec350040ff', |
||
| 255 | 'data' => [ |
||
| 256 | 'board' => [ |
||
| 257 | 'shortLink' => 'ZctgODOd', |
||
| 258 | 'name' => 'TEST', |
||
| 259 | 'id' => '5cdfb328cc5d0542a9bc5ce0' |
||
| 260 | ], |
||
| 261 | |||
| 262 | 'list' => [ |
||
| 263 | 'name' => 'ToDo', |
||
| 264 | 'id' => '5cdfb32f696b0a36d3186758' |
||
| 265 | ], |
||
| 266 | 'card' => [ |
||
| 267 | 'shortLink' => 'tZEJWg0V', |
||
| 268 | 'idShort' => '1', |
||
| 269 | 'name' => 'prima', |
||
| 270 | 'id' => $id |
||
| 271 | ] |
||
| 272 | ], |
||
| 273 | 'type' => 'createCard', |
||
| 274 | 'date' => '2019-05-17T06:45:04.392Z', |
||
| 275 | 'limits' => [], |
||
| 276 | 'memberCreator' => [ |
||
| 277 | 'id' => '521dbcdd68ba6dec350040ff', |
||
| 278 | 'avatarHash' => '3fab266d04a3f6f570b6a46606e133c0', |
||
| 279 | 'avatarUrl' => 'https://trello-avatars.s3.amazonaws.com/3fab266d04a3f6f570b6a46606e133c0', |
||
| 280 | 'fullName' => 'Alessandro Minoccheri', |
||
| 281 | 'idMemberReferrer' => '516a8b285b342af34f003c96', |
||
| 282 | 'initials' => 'AM' |
||
| 283 | ] |
||
| 284 | ] |
||
| 285 | ]; |
||
| 286 | |||
| 287 | |||
| 288 | $cardHistory = json_decode('[ |
||
| 289 | { |
||
| 290 | "id": "5ce7b60627e1bb5e0a8c60d1", |
||
| 291 | "idMemberCreator": "521dbcdd68ba6dec350040ff", |
||
| 292 | "data": { |
||
| 293 | "listAfter": { |
||
| 294 | "name": "DOne", |
||
| 295 | "id": "5cdfb33181899386ced12d14" |
||
| 296 | }, |
||
| 297 | "listBefore": { |
||
| 298 | "name": "Doing", |
||
| 299 | "id": "5cdfb3302e078d53fd5c01f8" |
||
| 300 | }, |
||
| 301 | "board": { |
||
| 302 | "shortLink": "ZctgODOd", |
||
| 303 | "name": "TEST", |
||
| 304 | "id": "5cdfb328cc5d0542a9bc5ce0" |
||
| 305 | }, |
||
| 306 | "card": { |
||
| 307 | "shortLink": "jV1haDyb", |
||
| 308 | "idShort": 1, |
||
| 309 | "name": "prima", |
||
| 310 | "id": "5cdfb33499236c320e7d772c", |
||
| 311 | "idList": "5cdfb33181899386ced12d14" |
||
| 312 | }, |
||
| 313 | "old": { |
||
| 314 | "idList": "5cdfb3302e078d53fd5c01f8" |
||
| 315 | } |
||
| 316 | }, |
||
| 317 | "type": "updateCard", |
||
| 318 | "date": "2019-05-24T09:14:46.642Z", |
||
| 319 | "limits": {}, |
||
| 320 | "memberCreator": { |
||
| 321 | "id": "521dbcdd68ba6dec350040ff", |
||
| 322 | "avatarHash": "3fab266d04a3f6f570b6a46606e133c0", |
||
| 323 | "avatarUrl": "https://trello-avatars.s3.amazonaws.com/3fab266d04a3f6f570b6a46606e133c0", |
||
| 324 | "fullName": "Alessandro Minoccheri", |
||
| 325 | "idMemberReferrer": "516a8b285b342af34f003c96", |
||
| 326 | "initials": "AM", |
||
| 327 | "nonPublic": {}, |
||
| 328 | "nonPublicAvailable": false, |
||
| 329 | "username": "alessandrominoccheri1" |
||
| 330 | } |
||
| 331 | }, |
||
| 332 | { |
||
| 333 | "id": "5cdfb33a2d9abb38dcaedbd8", |
||
| 334 | "idMemberCreator": "521dbcdd68ba6dec350040ff", |
||
| 335 | "data": { |
||
| 336 | "listAfter": { |
||
| 337 | "name": "Doing", |
||
| 338 | "id": "5cdfb3302e078d53fd5c01f8" |
||
| 339 | }, |
||
| 340 | "listBefore": { |
||
| 341 | "name": "ToDo", |
||
| 342 | "id": "5cdfb32f696b0a36d3186758" |
||
| 343 | }, |
||
| 344 | "board": { |
||
| 345 | "shortLink": "ZctgODOd", |
||
| 346 | "name": "TEST", |
||
| 347 | "id": "5cdfb328cc5d0542a9bc5ce0" |
||
| 348 | }, |
||
| 349 | "card": { |
||
| 350 | "shortLink": "jV1haDyb", |
||
| 351 | "idShort": 1, |
||
| 352 | "name": "prima", |
||
| 353 | "id": "5cdfb33499236c320e7d772c", |
||
| 354 | "idList": "5cdfb3302e078d53fd5c01f8" |
||
| 355 | }, |
||
| 356 | "old": { |
||
| 357 | "idList": "5cdfb32f696b0a36d3186758" |
||
| 358 | } |
||
| 359 | }, |
||
| 360 | "type": "updateCard", |
||
| 361 | "date": "2019-05-18T07:24:42.415Z", |
||
| 362 | "limits": {}, |
||
| 363 | "memberCreator": { |
||
| 364 | "id": "521dbcdd68ba6dec350040ff", |
||
| 365 | "avatarHash": "3fab266d04a3f6f570b6a46606e133c0", |
||
| 366 | "avatarUrl": "https://trello-avatars.s3.amazonaws.com/3fab266d04a3f6f570b6a46606e133c0", |
||
| 367 | "fullName": "Alessandro Minoccheri", |
||
| 368 | "idMemberReferrer": "516a8b285b342af34f003c96", |
||
| 369 | "initials": "AM", |
||
| 370 | "nonPublic": {}, |
||
| 371 | "nonPublicAvailable": false, |
||
| 372 | "username": "alessandrominoccheri1" |
||
| 373 | } |
||
| 374 | } |
||
| 375 | ]', true); |
||
| 376 | |||
| 377 | $boardId = 'boardId'; |
||
| 378 | |||
| 379 | $client->findCreationCard($id)->willReturn($creationCard); |
||
| 380 | |||
| 381 | $client->findAllCardHistory($id)->willReturn($cardHistory); |
||
| 382 | |||
| 383 | $trelloBoard = new TrelloBoard($client->reveal(), $boardId); |
||
| 384 | |||
| 385 | $cycleTimes = $trelloBoard->getCardTransitions($id); |
||
| 386 | |||
| 387 | $expected = [0 => [ |
||
| 388 | 'id' => $id, |
||
| 389 | 'title' => 'prima', |
||
| 390 | 'cycleTimes' => [ |
||
| 391 | 0 => [ |
||
| 392 | 'from' => 'Doing', |
||
| 393 | 'to' => 'DOne', |
||
| 394 | 'days' => '6', |
||
| 395 | 'name' => 'Doing_DOne' |
||
| 396 | ], |
||
| 397 | 1 => [ |
||
| 398 | 'from' => 'ToDo', |
||
| 399 | 'to' => 'Doing', |
||
| 400 | 'days' => '1', |
||
| 401 | 'name' => 'ToDo_Doing' |
||
| 402 | ] |
||
| 403 | ] |
||
| 404 | ] |
||
| 405 | ]; |
||
| 406 | |||
| 407 | $this->assertEquals($expected, $cycleTimes); |
||
| 408 | } |
||
| 409 | } |