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 |
||
| 16 | class Events |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * Optimizely API Client. |
||
| 20 | * @var WebMarketingROI\OptimizelyPHP\OptimizelyApiClient |
||
| 21 | */ |
||
| 22 | private $client; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Constructor. |
||
| 26 | */ |
||
| 27 | 6 | public function __construct($client) |
|
| 31 | |||
| 32 | /** |
||
| 33 | * Get all events for a Project |
||
| 34 | * @param integer $projectId |
||
| 35 | * @param integer $includeClassic |
||
| 36 | * @param integer $page |
||
| 37 | * @param integer $perPage |
||
| 38 | * @return array[Event] |
||
|
|
|||
| 39 | * @throws \Exception |
||
| 40 | */ |
||
| 41 | 1 | View Code Duplication | public function listAll($projectId, $includeClassic, $page=0, $perPage=10) |
| 67 | |||
| 68 | /** |
||
| 69 | * Get Event by ID |
||
| 70 | * @param type $eventId |
||
| 71 | * @return Event |
||
| 72 | * @throws \Exception |
||
| 73 | */ |
||
| 74 | 1 | View Code Duplication | public function get($eventId) |
| 86 | |||
| 87 | /** |
||
| 88 | * Creates a new click event. |
||
| 89 | * @param integer $pageId |
||
| 90 | * @param ClickEvent $event |
||
| 91 | */ |
||
| 92 | 1 | public function createClickEvent($pageId, $event) |
|
| 105 | |||
| 106 | /** |
||
| 107 | * Creates a new custom event. |
||
| 108 | * @param integer $pageId |
||
| 109 | * @param CustomEvent $event |
||
| 110 | */ |
||
| 111 | 1 | public function createCustomEvent($pageId, $event) |
|
| 124 | |||
| 125 | /** |
||
| 126 | * Updates the given click event. |
||
| 127 | * @param integer $pageId |
||
| 128 | * @param integer $eventId |
||
| 129 | * @param ClickEvent $event |
||
| 130 | * @throws \Exception |
||
| 131 | */ |
||
| 132 | 1 | View Code Duplication | public function updateClickEvent($pageId, $eventId, $event) |
| 145 | |||
| 146 | /** |
||
| 147 | * Updates the given custom event. |
||
| 148 | * @param integer $pageId |
||
| 149 | * @param integer $eventId |
||
| 150 | * @param CustomEvent $event |
||
| 151 | * @throws \Exception |
||
| 152 | */ |
||
| 153 | 1 | View Code Duplication | public function updateCustomEvent($pageId, $eventId, $event) |
| 166 | } |
||
| 167 | |||
| 172 |
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.