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 |
||
4 | class Content { |
||
5 | |||
6 | private static $host; |
||
|
|||
7 | private static $path; |
||
8 | private static $config; |
||
9 | private static $js; |
||
10 | private static $css; |
||
11 | private static $app; |
||
12 | private static $view; |
||
13 | private static $widget; |
||
14 | private static $title; |
||
15 | private static $description; |
||
16 | private static $keywords; |
||
17 | private static $uri; |
||
18 | |||
19 | View Code Duplication | public function __construct(){ |
|
20 | # Config |
||
21 | self::$config = (new Config)->get(); |
||
22 | # Application |
||
23 | self::$app = new Application; |
||
24 | # View |
||
25 | self::$view = new View; |
||
26 | # Widget |
||
27 | self::$widget = new Widget; |
||
28 | # Js |
||
29 | self::$js = new Js; |
||
30 | # Css |
||
31 | self::$css = new Css; |
||
32 | # Title |
||
33 | self::$title = new Title; |
||
34 | # Desctiption |
||
35 | self::$description = new Description; |
||
36 | # Keywords |
||
37 | self::$keywords = new Keywords; |
||
38 | # Uri |
||
39 | self::$uri = new Uri; |
||
40 | } |
||
41 | |||
42 | public function view($name){ |
||
46 | |||
47 | public function page(){ |
||
74 | |||
75 | public function js($query){ |
||
78 | |||
79 | # $type - page,view |
||
80 | public function file($name=false){ |
||
109 | |||
110 | } |
||
111 | ?> |
||
112 |
This check marks private properties in classes that are never used. Those properties can be removed.