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 |
||
| 11 | class MarathonApiClient implements ApiClientInterface |
||
| 12 | { |
||
| 13 | |||
| 14 | /** @var HttpClientInterface */ |
||
| 15 | private $httpClient; |
||
| 16 | |||
| 17 | 9 | public function __construct( |
|
| 22 | |||
| 23 | /** |
||
| 24 | * @link: https://mesos.github.io/chronos/docs/api.html#listing-jobs |
||
| 25 | * @return array |
||
| 26 | */ |
||
| 27 | 1 | View Code Duplication | public function listingJobs() |
| 36 | |||
| 37 | /** |
||
| 38 | * @param JobEntityInterface $jobEntity |
||
| 39 | * @return bool |
||
| 40 | */ |
||
| 41 | 1 | public function addingJob(JobEntityInterface $jobEntity) |
|
| 48 | |||
| 49 | /** |
||
| 50 | * @param JobEntityInterface|ChronosJobEntity $jobEntity |
||
| 51 | * @return bool |
||
| 52 | */ |
||
| 53 | 1 | public function updatingJob(JobEntityInterface $jobEntity) |
|
| 61 | |||
| 62 | /** |
||
| 63 | * @param string $jobName |
||
| 64 | * @return bool |
||
| 65 | */ |
||
| 66 | 1 | public function removeJob($jobName) |
|
| 73 | |||
| 74 | /** |
||
| 75 | * @param string $jobName |
||
| 76 | * @return array |
||
| 77 | */ |
||
| 78 | public function getJobStats($jobName) |
||
| 82 | |||
| 83 | /** |
||
| 84 | * Returns true if the client can be connected to. |
||
| 85 | * @return bool |
||
| 86 | */ |
||
| 87 | 5 | View Code Duplication | public function ping() |
| 100 | } |
||
| 101 |