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 |
||
| 45 | class SyncContact extends Base { |
||
| 46 | |||
| 47 | |||
| 48 | /** @var DavService */ |
||
| 49 | private $davService; |
||
| 50 | |||
| 51 | |||
| 52 | /** |
||
| 53 | * Groups constructor. |
||
| 54 | * |
||
| 55 | * @param DavService $davService |
||
| 56 | */ |
||
| 57 | public function __construct(DavService $davService) { |
||
| 62 | |||
| 63 | |||
| 64 | protected function configure() { |
||
| 69 | |||
| 70 | |||
| 71 | protected function execute(InputInterface $input, OutputInterface $output) { |
||
| 76 | |||
| 77 | |||
| 78 | /** |
||
| 79 | * @param InputInterface $input |
||
| 80 | * @param OutputInterface $output |
||
| 81 | * |
||
| 82 | * @throws FakeException |
||
| 83 | */ |
||
| 84 | private function listLinkedGroups(InputInterface $input, OutputInterface $output) { |
||
| 91 | |||
| 92 | |||
| 93 | /** |
||
| 94 | * @param InputInterface $input |
||
| 95 | * @param OutputInterface $output |
||
| 96 | * |
||
| 97 | * @throws FakeException |
||
| 98 | */ |
||
| 99 | View Code Duplication | private function addLinkedGroups(InputInterface $input, OutputInterface $output) { |
|
| 108 | |||
| 109 | |||
| 110 | /** |
||
| 111 | * @param InputInterface $input |
||
| 112 | * @param OutputInterface $output |
||
| 113 | * |
||
| 114 | * @throws FakeException |
||
| 115 | */ |
||
| 116 | View Code Duplication | private function delLinkedGroups(InputInterface $input, OutputInterface $output) { |
|
| 125 | |||
| 126 | |||
| 127 | View Code Duplication | private function getCircleIdAndGroupFromArguments(InputInterface $input) { |
|
| 138 | |||
| 139 | } |
||
| 140 | |||
| 141 |