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 |
||
| 16 | class SessionRequests extends Route |
||
| 17 | { |
||
| 18 | |||
| 19 | /** |
||
| 20 | * returns true if the current request matches this route |
||
| 21 | * |
||
| 22 | * @return bool |
||
| 23 | * @since $VID:$ |
||
| 24 | */ |
||
| 25 | public function matchesCurrentRequest() |
||
| 29 | |||
| 30 | |||
| 31 | /** |
||
| 32 | * @since $VID:$ |
||
| 33 | */ |
||
| 34 | View Code Duplication | protected function registerDependencies() |
|
| 35 | { |
||
| 36 | $this->dependency_map->registerDependencies( |
||
| 37 | 'EE_Session', |
||
| 38 | [ |
||
| 39 | 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
||
| 40 | 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
||
| 41 | 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
||
| 42 | 'EventEspresso\core\services\session\SessionStartHandler' => EE_Dependency_Map::load_from_cache, |
||
| 43 | 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
||
| 44 | ] |
||
| 45 | ); |
||
| 46 | $this->dependency_map->registerDependencies( |
||
| 47 | 'EventEspresso\core\services\session\SessionStartHandler', |
||
| 48 | ['EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache] |
||
| 49 | ); |
||
| 50 | } |
||
| 51 | |||
| 52 | |||
| 53 | /** |
||
| 54 | * implements logic required to run during request |
||
| 55 | * |
||
| 56 | * @return bool |
||
| 57 | * @since $VID:$ |
||
| 58 | */ |
||
| 59 | protected function requestHandler() |
||
| 64 | } |
||
| 65 |