We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 3 |
| Paths | 4 |
| Total Lines | 57 |
| Code Lines | 39 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| 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 declare(strict_types=1); |
||
| 68 | public function test_vote_button_properties(): void { |
||
| 69 | // Set some arbitrary test data |
||
| 70 | $accountID = 7; |
||
| 71 | $gameID = 42; |
||
| 72 | |||
| 73 | // Set expected results when free turns are available |
||
| 74 | $expected = [ |
||
| 75 | VoteSite::TWG->value => [ |
||
| 76 | 'img' => 'twg_vote.png', |
||
| 77 | 'url' => 'http://topwebgames.com/in.aspx?ID=136&account=7&game=42&link=3&alwaysreward=1', |
||
| 78 | 'sn' => LOADER_URI . '?sn=gbuyay', |
||
| 79 | ], |
||
| 80 | VoteSite::DOG->value => [ |
||
| 81 | 'img' => 'dog_vote.png', |
||
| 82 | 'url' => 'http://www.directoryofgames.com/main.php?view=topgames&action=vote&v_tgame=2315&votedef=7,42,4', |
||
| 83 | 'sn' => LOADER_URI . '?sn=wnpclr', |
||
| 84 | ], |
||
| 85 | VoteSite::PBBG->value => [ |
||
| 86 | 'img' => 'pbbg.png', |
||
| 87 | 'url' => 'https://pbbg.com/games/space-merchant-realms', |
||
| 88 | 'sn' => false, |
||
| 89 | ], |
||
| 90 | ]; |
||
| 91 | |||
| 92 | srand(123); // set rand seed for session href generation |
||
| 93 | foreach ($expected as $siteID => $data) { |
||
| 94 | $link = new VoteLink(VoteSite::from($siteID), $accountID, $gameID); |
||
| 95 | self::assertSame($data['img'], $link->getImg()); |
||
| 96 | self::assertSame($data['url'], $link->getUrl()); |
||
| 97 | self::assertSame($data['sn'], $link->getSN()); |
||
| 98 | } |
||
| 99 | |||
| 100 | // Set expected results when free turns are NOT available |
||
| 101 | $expected = [ |
||
| 102 | VoteSite::TWG->value => [ |
||
| 103 | 'img' => 'twg.png', |
||
| 104 | 'url' => 'http://topwebgames.com/in.aspx?ID=136', |
||
| 105 | 'sn' => false, |
||
| 106 | ], |
||
| 107 | VoteSite::DOG->value => [ |
||
| 108 | 'img' => 'dog.png', |
||
| 109 | 'url' => 'http://www.directoryofgames.com/main.php?view=topgames&action=vote&v_tgame=2315', |
||
| 110 | 'sn' => false, |
||
| 111 | ], |
||
| 112 | VoteSite::PBBG->value => [ |
||
| 113 | 'img' => 'pbbg.png', |
||
| 114 | 'url' => 'https://pbbg.com/games/space-merchant-realms', |
||
| 115 | 'sn' => false, |
||
| 116 | ], |
||
| 117 | ]; |
||
| 118 | |||
| 119 | foreach ($expected as $siteID => $data) { |
||
| 120 | // game ID 0 suppresses free turn links |
||
| 121 | $link = new VoteLink(VoteSite::from($siteID), $accountID, 0); |
||
| 122 | self::assertSame($data['img'], $link->getImg()); |
||
| 123 | self::assertSame($data['url'], $link->getUrl()); |
||
| 124 | self::assertSame($data['sn'], $link->getSN()); |
||
| 125 | } |
||
| 162 |