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 |
||
| 20 | class AdminPageFramework_Debug_Base extends AdminPageFramework_FrameworkUtility { |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Returns a legible value representation with value details. |
||
| 24 | * @since 3.8.9 |
||
| 25 | * @return string |
||
| 26 | */ |
||
| 27 | static protected function _getLegibleDetails( $mValue ) { |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Returns a string representation of the given value. |
||
| 37 | * @since 3.8.9 |
||
| 38 | * @return string |
||
| 39 | */ |
||
| 40 | static protected function _getLegible( $mValue ) { |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Returns a object name if it is an object. Otherwise, the value itself. |
||
| 60 | * This is used to convert objects into a string in array-walk functions |
||
| 61 | * as objects tent to get large when they are converted to a string representation. |
||
| 62 | * @since 3.8.9 |
||
| 63 | */ |
||
| 64 | static private function _getObjectName( $mItem ) { |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @since 3.8.9 |
||
| 73 | * @param callable $asoCallable |
||
| 74 | * @return string |
||
| 75 | */ |
||
| 76 | static private function _getLegibleCallable( $asoCallable ) { |
||
| 79 | /** |
||
| 80 | * @since 3.8.9 |
||
| 81 | * @param callable $asoCallable |
||
| 82 | * @return string |
||
| 83 | */ |
||
| 84 | static public function _getCallableName( $asoCallable ) { |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @since 3.8.9 |
||
| 102 | * @param object $oObject |
||
| 103 | * @return string |
||
| 104 | */ |
||
| 105 | static public function _getLegibleObject( $oObject ) { |
||
| 114 | /** |
||
| 115 | * Returns an array representation with value types in each element. |
||
| 116 | * The element deeper than 10 dimensions will be dropped. |
||
| 117 | * @since 3.8.9 |
||
| 118 | * @return array |
||
| 119 | */ |
||
| 120 | static public function _getLegibleArray( array $aArray ) { |
||
| 126 | /** |
||
| 127 | * @since 3.8.9 |
||
| 128 | * @return string |
||
| 129 | */ |
||
| 130 | static private function _getLegibleValue( $mItem ) { |
||
| 138 | /** |
||
| 139 | * @since 3.8.9 |
||
| 140 | * @return string |
||
| 141 | */ |
||
| 142 | static private function _getLegibleNonScalar( $mNonScalar ) { |
||
| 157 | /** |
||
| 158 | * @return string |
||
| 159 | * @param scalar $sScalar |
||
| 160 | * @since 3.8.9 |
||
| 161 | */ |
||
| 162 | static private function _getLegibleScalar( $sScalar ) { |
||
| 171 | /** |
||
| 172 | * Returns a length of a value. |
||
| 173 | * @since 3.5.3 |
||
| 174 | * @internal |
||
| 175 | * @return integer|null For string or integer, the string length. For array, the element lengths. For other types, null. |
||
| 176 | */ |
||
| 177 | static private function _getValueLength( $mValue ) { |
||
| 188 | /** |
||
| 189 | * @param string $sString |
||
| 190 | * @param integer $iCharLimit Character length limit to truncate. |
||
| 191 | * @return string |
||
| 192 | */ |
||
| 193 | static private function _getLegibleString( $sString, $iCharLimit=200 ) { |
||
| 207 | |||
| 208 | /** |
||
| 209 | * @return string |
||
| 210 | * @since 3.8.9 |
||
| 211 | */ |
||
| 212 | static protected function _getArrayRepresentationSanitized( $sString ) { |
||
| 230 | |||
| 231 | /** |
||
| 232 | * Slices an array by the given depth. |
||
| 233 | * |
||
| 234 | * @since 3.4.4 |
||
| 235 | * @since 3.8.9 Changed it not to convert an object into an array. |
||
| 236 | * @since 3.8.9 Changed the scope to private. |
||
| 237 | * @since 3.8.9 Renamed from `getSliceByDepth()`. |
||
| 238 | * @return array |
||
| 239 | * @internal |
||
| 240 | */ |
||
| 241 | static private function _getSlicedByDepth( array $aSubject, $iDepth=0 ) { |
||
| 257 | |||
| 258 | /** |
||
| 259 | * Performs `array_map()` recursively. |
||
| 260 | * @return array |
||
| 261 | * @since 3.8.9 |
||
| 262 | */ |
||
| 263 | static private function _getArrayMappedRecursive( array $aArray, $oCallable ) { |
||
| 271 | static private $_oCurrentCallableForArrayMapRecursive; |
||
| 272 | /** |
||
| 273 | * @internal |
||
| 274 | * @return mixed A modified value. |
||
| 275 | * @since 3.8.9 |
||
| 276 | */ |
||
| 277 | static private function _getArrayMappedNested( $mItem ) { |
||
| 282 | |||
| 283 | } |
||
| 284 |