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 |
||
| 8 | class BackpackBaseConfigService |
||
| 9 | { |
||
| 10 | use ValueReplacerTrait; |
||
| 11 | |||
| 12 | private $command; |
||
| 13 | |||
| 14 | private $keys = [ |
||
|
|
|||
| 15 | "project_name", |
||
| 16 | "logo_lg", |
||
| 17 | "logo_mini", |
||
| 18 | "developer_name", |
||
| 19 | "developer_link", |
||
| 20 | "show_powered_by", |
||
| 21 | "skin", |
||
| 22 | "default_date_format", |
||
| 23 | "default_datetime_format", |
||
| 24 | "route_prefix", |
||
| 25 | ]; |
||
| 26 | |||
| 27 | public function __construct(BrandingCommand $command, $file) |
||
| 28 | { |
||
| 29 | $this->command = $command; |
||
| 30 | $this->file = $file; |
||
| 31 | $this->appends = false; |
||
| 32 | $this->defaults= collect(collect($this->command->getDefaults('config'))->get('backpack_base')); |
||
| 33 | } |
||
| 34 | |||
| 35 | View Code Duplication | public function perform() |
|
| 49 | |||
| 50 | protected function escape($value) |
||
| 54 | |||
| 55 | protected function old($key) |
||
| 59 | |||
| 60 | protected function search($key, $old) |
||
| 64 | |||
| 65 | protected function replace($key, $value) { |
||
| 68 | } |
This check marks private properties in classes that are never used. Those properties can be removed.