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 |
||
32 | class LegalSettingsController extends Controller { |
||
33 | /** |
||
34 | * @var \OCP\IL10N |
||
35 | */ |
||
36 | private $l10n; |
||
37 | |||
38 | /** |
||
39 | * @var \OCP\IConfig |
||
40 | */ |
||
41 | private $config; |
||
42 | |||
43 | /** |
||
44 | * @param string $appName |
||
45 | * @param IRequest $request |
||
46 | * @param IL10N $l10n |
||
47 | * @param IConfig $config |
||
48 | */ |
||
49 | public function __construct($appName, |
||
58 | |||
59 | /** |
||
60 | * Store imprint URL |
||
61 | * |
||
62 | * @param string $imprintUrl |
||
63 | * |
||
64 | * @return array |
||
65 | */ |
||
66 | View Code Duplication | public function setImprintUrl($imprintUrl) { |
|
81 | |||
82 | /** |
||
83 | * Store privacy policy URL |
||
84 | * |
||
85 | * @param string $privacyPolicy |
||
86 | * |
||
87 | * @return array |
||
88 | */ |
||
89 | View Code Duplication | public function setPrivacyPolicyUrl($privacyPolicy) { |
|
104 | } |
||
105 |