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 |
||
14 | class SeoModule extends BaseModule implements BootstrapInterface |
||
15 | { |
||
16 | const NO_REDIRECT = 0; |
||
17 | const FROM_WWW = 1; |
||
18 | const FROM_WITHOUT_WWW = 2; |
||
19 | public $cacheConfig = [ |
||
20 | 'metaCache' => [ |
||
21 | 'name' => 'metas', |
||
22 | 'expire' => 86400, |
||
23 | ], |
||
24 | 'counterCache' => [ |
||
25 | 'name' => 'counters', |
||
26 | 'expire' => 86400, |
||
27 | ], |
||
28 | 'robotsCache' => [ |
||
29 | 'name' => 'robots', |
||
30 | 'expire' => 86400, |
||
31 | ], |
||
32 | ]; |
||
33 | public $include = []; |
||
34 | public $mainPage = ''; |
||
35 | /** |
||
36 | * @var int type of redirect from WWW or without WWW |
||
37 | */ |
||
38 | public $redirectWWW = self::NO_REDIRECT; |
||
39 | /** |
||
40 | * @var bool if true redirect from url with trailing slash |
||
41 | */ |
||
42 | public $redirectTrailingSlash = false; |
||
43 | |||
44 | public $analytics = [ |
||
45 | 'ecGoogle' => [ |
||
46 | 'active' => 0, |
||
47 | 'currency' => AnalyticsHandler::CURRENCY_MAIN, |
||
48 | ], |
||
49 | 'ecYandex' => [ |
||
50 | 'active' => 0, |
||
51 | 'currency' => AnalyticsHandler::CURRENCY_MAIN, |
||
52 | ], |
||
53 | ]; |
||
54 | |||
55 | /** |
||
56 | * @inheritdoc |
||
57 | */ |
||
58 | public function bootstrap($app) |
||
83 | |||
84 | /** |
||
85 | * @inheritdoc |
||
86 | */ |
||
87 | public function behaviors() |
||
97 | |||
98 | /** |
||
99 | * @return array prepared to dropdown list in configurable |
||
100 | */ |
||
101 | View Code Duplication | public static function getRedirectTypes() |
|
109 | |||
110 | /** |
||
111 | * If redirectWWW config make 301 redirect to www or not www domain |
||
112 | */ |
||
113 | public static function redirectWWW() |
||
140 | |||
141 | /** |
||
142 | * Make redirect from url with trailing slash |
||
143 | */ |
||
144 | public static function redirectSlash() |
||
152 | } |
||
153 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.