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 |
||
| 46 | class SyncContact extends Base { |
||
| 47 | |||
| 48 | |||
| 49 | /** @var DavService */ |
||
| 50 | private $davService; |
||
| 51 | |||
| 52 | |||
| 53 | /** |
||
| 54 | * Groups constructor. |
||
| 55 | * |
||
| 56 | * @param DavService $davService |
||
| 57 | */ |
||
| 58 | public function __construct(DavService $davService) { |
||
| 63 | |||
| 64 | |||
| 65 | protected function configure() { |
||
| 70 | |||
| 71 | |||
| 72 | /** |
||
| 73 | * @param InputInterface $input |
||
| 74 | * @param OutputInterface $output |
||
| 75 | * |
||
| 76 | * @return int|void|null |
||
| 77 | * @throws Exception |
||
| 78 | */ |
||
| 79 | protected function execute(InputInterface $input, OutputInterface $output) { |
||
| 84 | |||
| 85 | |||
| 86 | /** |
||
| 87 | * @param InputInterface $input |
||
| 88 | * @param OutputInterface $output |
||
| 89 | * |
||
| 90 | * @throws FakeException |
||
| 91 | */ |
||
| 92 | private function listLinkedGroups(InputInterface $input, OutputInterface $output) { |
||
| 99 | |||
| 100 | |||
| 101 | /** |
||
| 102 | * @param InputInterface $input |
||
| 103 | * @param OutputInterface $output |
||
| 104 | * |
||
| 105 | * @throws FakeException |
||
| 106 | */ |
||
| 107 | View Code Duplication | private function addLinkedGroups(InputInterface $input, OutputInterface $output) { |
|
| 116 | |||
| 117 | |||
| 118 | /** |
||
| 119 | * @param InputInterface $input |
||
| 120 | * @param OutputInterface $output |
||
| 121 | * |
||
| 122 | * @throws FakeException |
||
| 123 | */ |
||
| 124 | View Code Duplication | private function delLinkedGroups(InputInterface $input, OutputInterface $output) { |
|
| 133 | |||
| 134 | |||
| 135 | View Code Duplication | private function getCircleIdAndGroupFromArguments(InputInterface $input) { |
|
| 146 | |||
| 147 | } |
||
| 148 | |||
| 149 |