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 BridgeMarathon implements BridgeInterface |
||
20 | { |
||
21 | const CACHE_TIME_JOB_LIST = 60; |
||
22 | |||
23 | const CACHE_KEY_APP_LIST = 'marathon.app.list'; |
||
24 | |||
25 | /** |
||
26 | * @var \Chapi\Component\RemoteClients\ApiClientInterface |
||
27 | */ |
||
28 | private $apiClient; |
||
29 | /** |
||
30 | * @var JobValidatorServiceInterface |
||
31 | */ |
||
32 | private $jobEntityValidatorService; |
||
33 | /** |
||
34 | * @var CacheInterface |
||
35 | */ |
||
36 | private $cache; |
||
37 | /** |
||
38 | * @var LoggerInterface |
||
39 | */ |
||
40 | private $logger; |
||
41 | |||
42 | private $cacheHasToDelete = false; |
||
43 | |||
44 | 5 | View Code Duplication | public function __construct( |
55 | |||
56 | 5 | public function __destruct() |
|
62 | |||
63 | /** |
||
64 | * @return JobEntityInterface[] |
||
65 | */ |
||
66 | 1 | public function getJobs() |
|
78 | |||
79 | /** |
||
80 | * @param JobEntityInterface $jobEntity |
||
81 | * @return bool |
||
82 | */ |
||
83 | 2 | View Code Duplication | public function addJob(JobEntityInterface $jobEntity) |
91 | |||
92 | /** |
||
93 | * @param JobEntityInterface $jobEntity |
||
94 | * @return bool |
||
95 | */ |
||
96 | View Code Duplication | public function updateJob(JobEntityInterface $jobEntity) |
|
104 | |||
105 | /** |
||
106 | * @param JobEntityInterface $jobEntity |
||
107 | * @return bool |
||
108 | */ |
||
109 | 2 | View Code Duplication | public function removeJob(JobEntityInterface $jobEntity) |
117 | |||
118 | /** |
||
119 | * @return array|mixed |
||
120 | */ |
||
121 | 1 | private function getJobList() |
|
137 | } |
||
138 |