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 |
||
9 | class EnvService |
||
10 | { |
||
11 | use ValueReplacerTrait; |
||
12 | |||
13 | private $command; |
||
14 | |||
15 | private $keys = [ |
||
|
|||
16 | "APP_NAME", |
||
17 | "APP_URL", |
||
18 | "BACKPACK_LICENSE", |
||
19 | "BACKPACK_REGISTRATION_OPEN", |
||
20 | ]; |
||
21 | |||
22 | public function __construct(BrandingCommand $command, $env) |
||
29 | |||
30 | View Code Duplication | public function perform() |
|
42 | |||
43 | protected function old($key) |
||
47 | |||
48 | protected function escape($value) |
||
56 | } |
This check marks private properties in classes that are never used. Those properties can be removed.