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 |
||
19 | class ZohoDatabaseSyncZoho |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * @var Connection |
||
24 | */ |
||
25 | private $connection; |
||
26 | |||
27 | /** |
||
28 | * @var LoggerInterface |
||
29 | */ |
||
30 | private $logger; |
||
31 | |||
32 | /** |
||
33 | * @param \Wabel\Zoho\CRM\AbstractZohoDao[] $zohoDaos The list of Zoho DAOs to copy |
||
|
|||
34 | * @param Connection $connection |
||
35 | * |
||
36 | */ |
||
37 | public function __construct(Connection $connection, $prefix = 'zoho_', LoggerInterface $logger = null) |
||
47 | |||
48 | /** |
||
49 | * |
||
50 | * @param AbstractZohoDao $zohoDao |
||
51 | * @return array |
||
52 | */ |
||
53 | private function findMethodValues(AbstractZohoDao $zohoDao){ |
||
65 | |||
66 | /** |
||
67 | * Insert or Update rows. |
||
68 | * @param AbstractZohoDao $zohoDao |
||
69 | * @param string $localTable |
||
70 | */ |
||
71 | public function pushDataToZoho(AbstractZohoDao $zohoDao, $localTable, $update = false){ |
||
130 | |||
131 | /** |
||
132 | * Find the row to delete and remove to Zoho. |
||
133 | * @param AbstractZohoDao $zohoDao |
||
134 | * @param string $localTable |
||
135 | */ |
||
136 | public function deleteDataToZoho(AbstractZohoDao $zohoDao, $localTable){ |
||
151 | |||
152 | /** |
||
153 | * Run inserted rows to Zoho : local_insert. |
||
154 | * @param AbstractZohoDao $zohoDao |
||
155 | */ |
||
156 | public function pushInsertedRows(AbstractZohoDao $zohoDao){ |
||
159 | |||
160 | /** |
||
161 | * Run updated rows to Zoho : local_update. |
||
162 | * @param AbstractZohoDao $zohoDao |
||
163 | */ |
||
164 | public function pushUpdatedRows(AbstractZohoDao $zohoDao){ |
||
167 | |||
168 | /** |
||
169 | * Run deleted rows to Zoho : local_delete. |
||
170 | * @param AbstractZohoDao $zohoDao |
||
171 | */ |
||
172 | public function pushDeletedRows(AbstractZohoDao $zohoDao){ |
||
175 | |||
176 | /** |
||
177 | * Computes the name of the table based on the DAO plural module name. |
||
178 | * |
||
179 | * @param AbstractZohoDao $dao |
||
180 | * |
||
181 | * @return string |
||
182 | */ |
||
183 | View Code Duplication | private function getTableName(AbstractZohoDao $dao) |
|
190 | |||
191 | |||
192 | /** |
||
193 | * @param LoggerInterface $logger |
||
194 | */ |
||
195 | public function setLogger(LoggerInterface $logger) |
||
199 | |||
200 | |||
201 | } |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.