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 |
||
| 3 | class CoC_League |
||
| 4 | { |
||
| 5 | protected $api; |
||
| 6 | protected $leagueId; |
||
| 7 | protected $league = NULL; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Constructor of CoC_League |
||
| 11 | * |
||
| 12 | * @param $leagueId |
||
| 13 | */ |
||
| 14 | public function __construct($league) |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Gets an stdClass containing league-information |
||
| 30 | * |
||
| 31 | * @return stdClass, league |
||
|
|
|||
| 32 | */ |
||
| 33 | protected function getLeague() |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Sets the league by providing it's exact name |
||
| 56 | * |
||
| 57 | * @param string, league name |
||
| 58 | * @return bool, success or fail |
||
| 59 | */ |
||
| 60 | public function setLeagueByName($name) |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Gets the league ID |
||
| 76 | * |
||
| 77 | * @return int |
||
| 78 | */ |
||
| 79 | public function getLeagueId() |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Gets the league name |
||
| 86 | * |
||
| 87 | * @return string, name |
||
| 88 | */ |
||
| 89 | public function getLeagueName() |
||
| 93 | |||
| 94 | /** |
||
| 95 | * Sets the league by providing it's exact name |
||
| 96 | * |
||
| 97 | * @param (optional) $size ("tiny", "small", "medium") |
||
| 98 | * @return string, URL to the picture |
||
| 99 | */ |
||
| 100 | public function getLeagueIcon($size = "") //small, tiny, medium |
||
| 118 | } |
||
| 119 | |||
| 120 | ?> |
||
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.