Complex classes like AdminPageFramework_Debug_Base 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 AdminPageFramework_Debug_Base, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
18 | class AdminPageFramework_Debug_Base extends AdminPageFramework_FrameworkUtility { |
||
19 | |||
20 | /** |
||
21 | * Returns a legible value representation with value details. |
||
22 | * @since 3.8.9 |
||
23 | * @return string |
||
24 | */ |
||
25 | static protected function _getLegibleDetails( $mValue ) { |
||
32 | |||
33 | /** |
||
34 | * Returns a string representation of the given value. |
||
35 | * @since 3.8.9 |
||
36 | * @return string |
||
37 | */ |
||
38 | static protected function _getLegible( $mValue ) { |
||
55 | |||
56 | /** |
||
57 | * Returns a object name if it is an object. Otherwise, the value itself. |
||
58 | * This is used to convert objects into a string in array-walk functions |
||
59 | * as objects tent to get large when they are converted to a string representation. |
||
60 | * @since 3.8.9 |
||
61 | */ |
||
62 | static private function _getObjectName( $mItem ) { |
||
68 | |||
69 | /** |
||
70 | * @since 3.8.9 |
||
71 | * @param callable $asoCallable |
||
72 | * @return string |
||
73 | */ |
||
74 | static private function _getLegibleCallable( $asoCallable ) { |
||
89 | /** |
||
90 | * @since 3.8.9 |
||
91 | * @param object $oObject |
||
92 | * @return string |
||
93 | */ |
||
94 | static public function _getLegibleObject( $oObject ) { |
||
103 | /** |
||
104 | * Returns an array representation with value types in each element. |
||
105 | * The element deeper than 10 dimensions will be dropped. |
||
106 | * @since 3.8.9 |
||
107 | * @return array |
||
108 | */ |
||
109 | static public function _getLegibleArray( array $aArray ) { |
||
115 | /** |
||
116 | * @since 3.8.9 |
||
117 | * @return string |
||
118 | */ |
||
119 | static private function _getLegibleValue( $mItem ) { |
||
127 | /** |
||
128 | * @since 3.8.9 |
||
129 | * @return string |
||
130 | */ |
||
131 | static private function _getLegibleNonScalar( $mNonScalar ) { |
||
146 | /** |
||
147 | * @return string |
||
148 | * @param scalar $sScalar |
||
149 | * @param integer $iCharLimit Character length limit to truncate. |
||
150 | * @since 3.8.9 |
||
151 | */ |
||
152 | static private function _getLegibleScalar( $sScalar ) { |
||
161 | /** |
||
162 | * Returns a length of a value. |
||
163 | * @since 3.5.3 |
||
164 | * @internal |
||
165 | * @return integer|null For string or integer, the string length. For array, the element lengths. For other types, null. |
||
166 | */ |
||
167 | static private function _getValueLength( $mValue ) { |
||
178 | /** |
||
179 | * @return string |
||
180 | */ |
||
181 | static private function _getLegibleString( $sString, $iCharLimit=200 ) { |
||
195 | |||
196 | /** |
||
197 | * @return string |
||
198 | * @since 3.8.9 |
||
199 | */ |
||
200 | static protected function _getArrayRepresentationSanitized( $sString ) { |
||
218 | |||
219 | /** |
||
220 | * Slices an array by the given depth. |
||
221 | * |
||
222 | * @since 3.4.4 |
||
223 | * @since 3.8.9 Changed it not to convert an object into an array. |
||
224 | * @since 3.8.9 Changed the scope to private. |
||
225 | * @since 3.8.9 Renamed from `getSliceByDepth()`. |
||
226 | * @return array |
||
227 | * @internal |
||
228 | */ |
||
229 | static private function _getSlicedByDepth( array $aSubject, $iDepth=0 ) { |
||
245 | |||
246 | /** |
||
247 | * Performs `array_map()` recursively. |
||
248 | * @return array |
||
249 | * @since 3.8.9 |
||
250 | */ |
||
251 | static private function _getArrayMappedRecursive( array $aArray, $oCallable ) { |
||
259 | static private $_oCurrentCallableForArrayMapRecursive; |
||
260 | /** |
||
261 | * @internal |
||
262 | * @return mixed A modified value. |
||
263 | * @since 3.8.9 |
||
264 | */ |
||
265 | static private function _getArrayMappedNested( $mItem ) { |
||
270 | |||
271 | |||
272 | /* Deprecated Methods */ |
||
273 | |||
274 | /** |
||
275 | * Prints out the given variable contents. |
||
276 | * |
||
277 | * If a file pass is given, it saves the output in the file. |
||
278 | * |
||
279 | * @since unknown |
||
280 | * @deprecated 3.2.0 |
||
281 | */ |
||
282 | static public function dumpArray( $asArray, $sFilePath=null ) { |
||
286 | |||
287 | /** |
||
288 | * Retrieves the output of the given array contents. |
||
289 | * |
||
290 | * If a file pass is given, it saves the output in the file. |
||
291 | * |
||
292 | * @since 2.1.6 The $bEncloseInTag parameter is added. |
||
293 | * @since 3.0.0 Changed the $bEncloseInTag parameter to bEscape. |
||
294 | * @deprecated 3.2.0 |
||
295 | */ |
||
296 | static public function getArray( $asArray, $sFilePath=null, $bEscape=true ) { |
||
300 | |||
301 | /** |
||
302 | * Logs the given array output into the given file. |
||
303 | * |
||
304 | * @since 2.1.1 |
||
305 | * @since 3.0.3 Changed the default log location and file name. |
||
306 | * @deprecated 3.1.0 Use the `log()` method instead. |
||
307 | */ |
||
308 | static public function logArray( $asArray, $sFilePath=null ) { |
||
312 | |||
313 | /** |
||
314 | * Returns a string representation of the given value. |
||
315 | * @since 3.5.0 |
||
316 | * @param mixed $mValue The value to get as a string |
||
317 | * @internal |
||
318 | * @return string |
||
319 | * @deprecated 3.8.9 |
||
320 | */ |
||
321 | static public function getAsString( $mValue ) { |
||
325 | |||
326 | } |
||
327 |