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 |
||
| 33 | class RepairIdentityProofKeyFolders implements IRepairStep { |
||
| 34 | |||
| 35 | /** @var IConfig */ |
||
| 36 | private $config; |
||
| 37 | |||
| 38 | /** @var \OC\Files\AppData\AppData */ |
||
| 39 | private $appDataIdentityProof; |
||
| 40 | |||
| 41 | /** @var IRootFolder */ |
||
| 42 | private $rootFolder; |
||
| 43 | |||
| 44 | /** @var string */ |
||
| 45 | private $identityProofDir; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * RepairIdentityProofKeyFolders constructor. |
||
| 49 | * |
||
| 50 | * @param IConfig $config |
||
| 51 | * @param Factory $appDataFactory |
||
| 52 | * @param IRootFolder $rootFolder |
||
| 53 | */ |
||
| 54 | public function __construct(IConfig $config, Factory $appDataFactory, IRootFolder $rootFolder) { |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Returns the step's name |
||
| 68 | * |
||
| 69 | * @return string |
||
| 70 | * @since 9.1.0 |
||
| 71 | */ |
||
| 72 | public function getName() { |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Run repair step. |
||
| 78 | * Must throw exception on error. |
||
| 79 | * |
||
| 80 | * @param IOutput $output |
||
| 81 | * @throws \Exception in case of failure |
||
| 82 | * @since 9.1.0 |
||
| 83 | */ |
||
| 84 | View Code Duplication | public function run(IOutput $output) { |
|
| 91 | |||
| 92 | /** |
||
| 93 | * rename all dirs with user specific keys to 'user-uid' |
||
| 94 | * |
||
| 95 | * @return int |
||
| 96 | */ |
||
| 97 | private function repair() { |
||
| 110 | } |
||
| 111 |