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 |
||
14 | class Pages |
||
15 | { |
||
16 | /** |
||
17 | * Optimizely API Client. |
||
18 | * @var WebMarketingROI\OptimizelyPHP\OptimizelyApiClient |
||
19 | */ |
||
20 | private $client; |
||
21 | |||
22 | /** |
||
23 | * Constructor. |
||
24 | */ |
||
25 | 5 | public function __construct($client) |
|
29 | |||
30 | /** |
||
31 | * List all Pages for a project. |
||
32 | * @param integer $projectId |
||
33 | * @param integer $page |
||
34 | * @param integer $perPage |
||
35 | * @return array[Page] |
||
|
|||
36 | * @throws \Exception |
||
37 | */ |
||
38 | 1 | View Code Duplication | public function listAll($projectId, $page=0, $perPage=10) |
63 | |||
64 | /** |
||
65 | * Get metadata for a single Page |
||
66 | * @param integer $pageId |
||
67 | * @return Page |
||
68 | * @throws \Exception |
||
69 | */ |
||
70 | 1 | View Code Duplication | public function get($pageId) |
82 | |||
83 | /** |
||
84 | * Create a new Page in a provided Project |
||
85 | * @param Page $page |
||
86 | */ |
||
87 | 1 | public function create($page) |
|
100 | |||
101 | /** |
||
102 | * Update a Page in a provided Project |
||
103 | * @param integer $pageId |
||
104 | * @param Audience $page |
||
105 | * @throws \Exception |
||
106 | */ |
||
107 | 1 | public function update($pageId, $page) |
|
120 | |||
121 | /** |
||
122 | * Delete a Page within a Project by ID. |
||
123 | * @param integer $pageId |
||
124 | * @throws \Exception |
||
125 | */ |
||
126 | 1 | public function delete($pageId) |
|
131 | } |
||
132 | |||
138 |
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.