Complex classes like vsc 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 vsc, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
20 | class vsc extends BaseObject { |
||
21 | /** |
||
22 | * @var vsc |
||
23 | */ |
||
24 | static private $oInstance; |
||
25 | |||
26 | /** |
||
27 | * @var HttpRequestA |
||
28 | */ |
||
29 | private $oRequest = null; |
||
30 | |||
31 | /** |
||
32 | * @var HttpResponseA |
||
33 | */ |
||
34 | private $oResponse = null; |
||
35 | |||
36 | /** |
||
37 | * @var DispatcherA |
||
38 | */ |
||
39 | private $oDispatcher; |
||
40 | |||
41 | /** |
||
42 | * @param vsc $envObject |
||
43 | */ |
||
44 | 19 | public static function setInstance(vsc $envObject) { |
|
47 | |||
48 | /** |
||
49 | * @return vsc |
||
50 | */ |
||
51 | 26 | public static function getEnv() { |
|
57 | |||
58 | /** |
||
59 | * @param HttpRequestA $oRequest |
||
60 | */ |
||
61 | 18 | public function setHttpRequest(HttpRequestA $oRequest) { |
|
66 | |||
67 | /** |
||
68 | * @returns HttpRequestA |
||
69 | */ |
||
70 | 20 | public function getHttpRequest() { |
|
81 | |||
82 | /** |
||
83 | * @param HttpResponseA $oResponse |
||
84 | */ |
||
85 | 1 | public function setHttpResponse(HttpResponseA $oResponse) { |
|
90 | |||
91 | /** |
||
92 | * @returns HttpResponseA |
||
93 | */ |
||
94 | 1 | public function getHttpResponse() { |
|
100 | |||
101 | /** |
||
102 | * @param HttpDispatcherA $oDispatcher |
||
103 | */ |
||
104 | 1 | public function setDispatcher($oDispatcher) { |
|
109 | |||
110 | /** |
||
111 | * @returns HttpDispatcherA |
||
112 | */ |
||
113 | 3 | public function getDispatcher() { |
|
119 | |||
120 | /** |
||
121 | * @return SiteMapA |
||
122 | */ |
||
123 | 2 | public function getSiteMap() { |
|
126 | |||
127 | /** |
||
128 | * @return boolean |
||
129 | */ |
||
130 | 1 | public function isDevelopment() { |
|
138 | |||
139 | /** |
||
140 | * @return bool |
||
141 | */ |
||
142 | 4 | protected function _isCli() { |
|
145 | |||
146 | /** |
||
147 | * @return bool |
||
148 | */ |
||
149 | 5 | public static function isCli() { |
|
152 | |||
153 | /** |
||
154 | * @return string |
||
155 | */ |
||
156 | 1 | public static function name() { |
|
159 | |||
160 | /** |
||
161 | * returns an end of line, based on the environment |
||
162 | * @return string |
||
163 | */ |
||
164 | 1 | public static function nl() { |
|
167 | |||
168 | /** |
||
169 | * @param array ...$values |
||
170 | * @return string |
||
171 | */ |
||
172 | 1 | public static function d(...$values) { |
|
211 | |||
212 | 1 | public static function getIncludePaths() { |
|
215 | |||
216 | /** |
||
217 | * @returns ModuleMap |
||
218 | */ |
||
219 | 1 | public function getCurrentModuleMap() { |
|
222 | |||
223 | 1 | public static function getPaths() { |
|
226 | } |
||
227 |