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 ZohoDatabasePusher |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * @var Connection |
||
21 | */ |
||
22 | private $connection; |
||
23 | |||
24 | /** |
||
25 | * @var LoggerInterface |
||
26 | */ |
||
27 | private $logger; |
||
28 | |||
29 | /** |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | private $prefix; |
||
34 | |||
35 | /** |
||
36 | * @param Connection $connection |
||
37 | * @param string $prefix |
||
38 | * @param LoggerInterface $logger |
||
39 | */ |
||
40 | public function __construct(Connection $connection, $prefix = 'zoho_', LoggerInterface $logger = null) |
||
50 | |||
51 | /** |
||
52 | * |
||
53 | * @param AbstractZohoDao $zohoDao |
||
54 | * @return array |
||
55 | */ |
||
56 | private function findMethodValues(AbstractZohoDao $zohoDao){ |
||
69 | |||
70 | /** |
||
71 | * Insert or Update rows. |
||
72 | * @param AbstractZohoDao $zohoDao |
||
73 | * @param string $localTable |
||
74 | */ |
||
75 | public function pushDataToZoho(AbstractZohoDao $zohoDao, $update = false){ |
||
131 | |||
132 | /** |
||
133 | * Insert data to bean in order to insert zoho records. |
||
134 | * @param ZohoBeanInterface $zohoBean |
||
135 | * @param array $fieldsMatching |
||
136 | * @param array $row |
||
137 | */ |
||
138 | View Code Duplication | private function insertDataZohoBean(ZohoBeanInterface $zohoBean, array $fieldsMatching, array $row) |
|
148 | |||
149 | /** |
||
150 | * Insert data to bean in order to update zoho records. |
||
151 | * @param ZohoBeanInterface $zohoBean |
||
152 | * @param array $fieldsMatching |
||
153 | * @param type $columnName |
||
154 | * @param type $valueDb |
||
155 | */ |
||
156 | View Code Duplication | private function updateDataZohoBean(ZohoBeanInterface $zohoBean, array $fieldsMatching, $columnName, $valueDb){ |
|
163 | |||
164 | /** |
||
165 | * Change the value to the good format. |
||
166 | * @param string $type |
||
167 | * @param mixed $value |
||
168 | * @return mixed |
||
169 | */ |
||
170 | private function formatValueToBeans($type ,$value) |
||
182 | |||
183 | /** |
||
184 | * Run deleted rows to Zoho : local_delete. |
||
185 | * @param AbstractZohoDao $zohoDao |
||
186 | */ |
||
187 | public function pushDeletedRows(AbstractZohoDao $zohoDao){ |
||
203 | |||
204 | /** |
||
205 | * Run inserted rows to Zoho : local_insert. |
||
206 | * @param AbstractZohoDao $zohoDao |
||
207 | */ |
||
208 | public function pushInsertedRows(AbstractZohoDao $zohoDao){ |
||
211 | |||
212 | /** |
||
213 | * Run updated rows to Zoho : local_update. |
||
214 | * @param AbstractZohoDao $zohoDao |
||
215 | */ |
||
216 | public function pushUpdatedRows(AbstractZohoDao $zohoDao){ |
||
219 | |||
220 | /** |
||
221 | * Push data from db to Zoho. |
||
222 | * @param AbstractZohoDao $zohoDao |
||
223 | */ |
||
224 | public function pushToZoho(AbstractZohoDao $zohoDao) |
||
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.