Complex classes like Application often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Application, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
14 | class Application extends CompressableExternalModule |
||
|
|||
15 | { |
||
16 | const EVENT_IS_CMS = 'samsonsms.is.cms'; |
||
17 | |||
18 | /** @var string Module identifier */ |
||
19 | public $id = 'cms'; |
||
20 | |||
21 | public $baseUrl = 'cms'; |
||
22 | |||
23 | /** @var array Collection of SamsonCMS related modules */ |
||
24 | protected $moduleList = []; |
||
25 | |||
26 | /** @var bool Flag that currently we are woring in SamsonCMS */ |
||
27 | protected $isCMS = false; |
||
28 | |||
29 | //[PHPCOMPRESSOR(remove,start)] |
||
30 | /** |
||
31 | * Remove unnecessary modules list for SamsonCMS from loaded modules |
||
32 | * and return left modules. |
||
33 | * |
||
34 | * @param array $otherModuleList List of SamsonCMS unneeded modules |
||
35 | */ |
||
36 | public function filterModuleList(&$otherModuleList = []) |
||
68 | |||
69 | /** |
||
70 | * Check if passed module is related to SamsonCMS. |
||
71 | * Also method stores data to flag variable. |
||
72 | * |
||
73 | * @param $module |
||
74 | * |
||
75 | * @return bool True if module related to SamsonCMS |
||
76 | */ |
||
77 | public function ifModuleRelated($module) |
||
82 | |||
83 | /** SamsonCMS preparation stage handler */ |
||
84 | public function prepare() |
||
92 | |||
93 | /** |
||
94 | * If module is dependent from current module through composer.json. |
||
95 | * |
||
96 | * @param $module Module for checking |
||
97 | * @return bool True if module dependent |
||
98 | */ |
||
99 | protected function isModuleDependent($module) |
||
103 | |||
104 | //[PHPCOMPRESSOR(remove,end)] |
||
105 | |||
106 | /** |
||
107 | * SamsonCMS initialization stage handler |
||
108 | * |
||
109 | * @param array $params Initialization parameters |
||
110 | * |
||
111 | * @return bool Initialization stage result |
||
112 | */ |
||
113 | public function init(array $params = array()) |
||
134 | |||
135 | public function isCMS() |
||
139 | |||
140 | public function activeModuleHandler($module) |
||
153 | |||
154 | /** |
||
155 | * Callback for adding SamsonCMS related modules prefix to routes. |
||
156 | * |
||
157 | * @param $module |
||
158 | * @param $prefix |
||
159 | */ |
||
160 | public function updateCMSPrefix($module, &$prefix) |
||
166 | |||
167 | public function buildUrl(&$urlObj, &$httpHost, &$urlParams) |
||
178 | |||
179 | public function parseUrl(&$urlObj, &$urlArgs) |
||
190 | |||
191 | public function __base() |
||
201 | |||
202 | public function oldMainRenderer(&$html) |
||
212 | |||
213 | /** |
||
214 | * @deprecated All application should draw menu block via events |
||
215 | */ |
||
216 | public function oldMenuRenderer(&$html, &$subMenu) |
||
251 | |||
252 | /** |
||
253 | * @deprecated |
||
254 | * @return string Page title |
||
255 | */ |
||
256 | public function oldGetTitle() |
||
264 | } |
||
265 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.