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) |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @inheritdoc |
||
| 84 | */ |
||
| 85 | public function behaviors() |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @return array prepared to dropdown list in configurable |
||
| 98 | */ |
||
| 99 | View Code Duplication | public static function getRedirectTypes() |
|
| 107 | |||
| 108 | /** |
||
| 109 | * If redirectWWW config make 301 redirect to www or not www domain |
||
| 110 | */ |
||
| 111 | public static function redirectWWW() |
||
| 138 | |||
| 139 | /** |
||
| 140 | * Make redirect from url with trailing slash |
||
| 141 | */ |
||
| 142 | public static function redirectSlash() |
||
| 150 | } |
||
| 151 |