Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php | ||
| 15 | View Code Duplication | class Team | |
| 16 | { | ||
| 17 | /** @var TwitchRequest */ | ||
| 18 | protected $request; | ||
| 19 | |||
| 20 | const URI_TEAM = 'teams/'; | ||
| 21 | const URI_TEAMS = 'teams'; | ||
| 22 | |||
| 23 | /** | ||
| 24 | * Team constructor | ||
| 25 | * @param TwitchRequest $request | ||
| 26 | */ | ||
| 27 | public function __construct(TwitchRequest $request) | ||
| 31 | |||
| 32 | /** | ||
| 33 | * Get the specified team | ||
| 34 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/teams.md#get-teamsteam | ||
| 35 | * @param string $team | ||
| 36 | * @return \stdClass | ||
| 37 | * @throws TwitchSDKException | ||
| 38 | */ | ||
| 39 | public function getTeam($team) | ||
| 43 | |||
| 44 | /** | ||
| 45 | * Returns a list of active teams | ||
| 46 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/teams.md#get-teams | ||
| 47 | * @param $queryString | ||
| 48 | * @return \stdClass | ||
| 49 | * @throws TwitchSDKException | ||
| 50 | */ | ||
| 51 | public function getTeams($queryString) | ||
| 55 | } | ||
| 56 |