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 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | private $prefix; |
||
37 | |||
38 | /** |
||
39 | * @param Connection $connection |
||
40 | * @param string $prefix |
||
41 | * @param LoggerInterface $logger |
||
42 | */ |
||
43 | public function __construct(Connection $connection, $prefix = 'zoho_', LoggerInterface $logger = null) |
||
53 | |||
54 | /** |
||
55 | * |
||
56 | * @param AbstractZohoDao $zohoDao |
||
57 | * @return array |
||
58 | */ |
||
59 | private function findMethodValues(AbstractZohoDao $zohoDao){ |
||
72 | |||
73 | /** |
||
74 | * Insert or Update rows. |
||
75 | * @param AbstractZohoDao $zohoDao |
||
76 | * @param string $localTable |
||
77 | */ |
||
78 | public function pushDataToZoho(AbstractZohoDao $zohoDao, $localTable, $update = false){ |
||
138 | |||
139 | /** |
||
140 | * Change the value to the good format. |
||
141 | * @param string $moduleName |
||
142 | * @param array $fieldsMatching |
||
143 | * @param string $columnName |
||
144 | * @param mixed $value |
||
145 | * @param int $id |
||
146 | * @return mixed |
||
147 | * @throws ZohoCRMException |
||
148 | */ |
||
149 | private function formatValueToBeans($moduleName, $fieldsMatching,$columnName,$value,$id=null, $uid = null) |
||
172 | |||
173 | /** |
||
174 | * Find the row to delete and remove to Zoho. |
||
175 | * @param AbstractZohoDao $zohoDao |
||
176 | * @param string $localTable |
||
177 | */ |
||
178 | public function deleteDataToZoho(AbstractZohoDao $zohoDao, $localTable){ |
||
193 | |||
194 | /** |
||
195 | * Run inserted rows to Zoho : local_insert. |
||
196 | * @param AbstractZohoDao $zohoDao |
||
197 | */ |
||
198 | public function pushInsertedRows(AbstractZohoDao $zohoDao){ |
||
201 | |||
202 | /** |
||
203 | * Run updated rows to Zoho : local_update. |
||
204 | * @param AbstractZohoDao $zohoDao |
||
205 | */ |
||
206 | public function pushUpdatedRows(AbstractZohoDao $zohoDao){ |
||
209 | |||
210 | /** |
||
211 | * Run deleted rows to Zoho : local_delete. |
||
212 | * @param AbstractZohoDao $zohoDao |
||
213 | */ |
||
214 | public function pushDeletedRows(AbstractZohoDao $zohoDao){ |
||
217 | |||
218 | /** |
||
219 | * Computes the name of the table based on the DAO plural module name. |
||
220 | * |
||
221 | * @param AbstractZohoDao $dao |
||
222 | * |
||
223 | * @return string |
||
224 | */ |
||
225 | View Code Duplication | private function getTableName(AbstractZohoDao $dao) |
|
232 | |||
233 | |||
234 | /** |
||
235 | * @param LoggerInterface $logger |
||
236 | */ |
||
237 | public function setLogger(LoggerInterface $logger) |
||
241 | |||
242 | |||
243 | } |
This check looks for access to methods that are not accessible from the current context.
If you need to make a method accessible to another context you can raise its visibility level in the defining class.