Complex classes like ExcessivePublicCountWorksForPublicStaticMethods 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 ExcessivePublicCountWorksForPublicStaticMethods, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 20 | class ExcessivePublicCountWorksForPublicStaticMethods |
||
| 21 | { |
||
| 22 | public static function aMethod() |
||
| 25 | |||
| 26 | public static function bMethod() |
||
| 29 | |||
| 30 | public static function cMethod() |
||
| 33 | |||
| 34 | public static function dMethod() |
||
| 37 | |||
| 38 | public static function eMethod() |
||
| 41 | |||
| 42 | public static function fMethod() |
||
| 45 | |||
| 46 | public static function gMethod() |
||
| 49 | |||
| 50 | public static function hMethod() |
||
| 53 | |||
| 54 | public static function iMethod() |
||
| 57 | |||
| 58 | public static function jMethod() |
||
| 61 | |||
| 62 | public static function kMethod() |
||
| 65 | |||
| 66 | public static function lMethod() |
||
| 69 | |||
| 70 | public static function mMethod() |
||
| 73 | |||
| 74 | public static function nMethod() |
||
| 77 | |||
| 78 | public static function oMethod() |
||
| 81 | |||
| 82 | public static function pMethod() |
||
| 85 | |||
| 86 | public static function rMethod() |
||
| 89 | |||
| 90 | public static function sMethod() |
||
| 93 | |||
| 94 | public static function tMethod() |
||
| 97 | |||
| 98 | public static function uMethod() |
||
| 101 | |||
| 102 | public static function wMethod() |
||
| 105 | |||
| 106 | public static function xMethod() |
||
| 109 | |||
| 110 | public static function yMethod() |
||
| 113 | |||
| 114 | public static function zMethod() |
||
| 117 | |||
| 118 | public static function aaMethod() |
||
| 121 | |||
| 122 | public static function abMethod() |
||
| 125 | |||
| 126 | public static function acMethod() |
||
| 129 | |||
| 130 | public static function adMethod() |
||
| 133 | |||
| 134 | public static function aeMethod() |
||
| 137 | |||
| 138 | public static function afMethod() |
||
| 141 | |||
| 142 | public static function agMethod() |
||
| 145 | |||
| 146 | public static function ahMethod() |
||
| 149 | |||
| 150 | public static function ajMethod() |
||
| 153 | |||
| 154 | public static function akMethod() |
||
| 157 | |||
| 158 | public static function alMethod() |
||
| 161 | |||
| 162 | public static function amMethod() |
||
| 165 | |||
| 166 | public static function anMethod() |
||
| 169 | |||
| 170 | public static function aoMethod() |
||
| 173 | |||
| 174 | public static function apMethod() |
||
| 177 | |||
| 178 | public static function arMethod() |
||
| 181 | |||
| 182 | public static function asMethod() |
||
| 185 | |||
| 186 | public static function atMethod() |
||
| 189 | |||
| 190 | public static function auMethod() |
||
| 193 | |||
| 194 | public static function awMethod() |
||
| 197 | |||
| 198 | public static function axMethod() |
||
| 201 | |||
| 202 | public static function ayMethod() |
||
| 205 | |||
| 206 | public static function azMethod() |
||
| 209 | |||
| 210 | public static function baMethod() |
||
| 213 | |||
| 214 | public static function bbMethod() |
||
| 217 | |||
| 218 | public static function bcMethod() |
||
| 221 | |||
| 222 | public static function bdMethod() |
||
| 225 | |||
| 226 | public static function beMethod() |
||
| 229 | |||
| 230 | public static function bfMethod() |
||
| 233 | |||
| 234 | public static function bgMethod() |
||
| 237 | |||
| 238 | public static function bhMethod() |
||
| 241 | |||
| 242 | public static function biMethod() |
||
| 245 | |||
| 246 | public static function bjMethod() |
||
| 249 | |||
| 250 | public static function bkMethod() |
||
| 253 | |||
| 254 | public static function blmethod() |
||
| 257 | |||
| 258 | public static function bmmethod() |
||
| 261 | |||
| 262 | public static function bnMethod() |
||
| 265 | |||
| 266 | public static function boMethod() |
||
| 269 | |||
| 270 | public static function bpMethod() |
||
| 273 | |||
| 274 | public static function brMethod() |
||
| 277 | |||
| 278 | public static function bsMethod() |
||
| 281 | |||
| 282 | public static function btMethod() |
||
| 285 | |||
| 286 | public static function buMethod() |
||
| 289 | |||
| 290 | public static function bwMethod() |
||
| 293 | |||
| 294 | public static function bxMethod() |
||
| 297 | |||
| 298 | public static function byMethod() |
||
| 301 | |||
| 302 | public static function bzMethod() |
||
| 305 | } |
||
| 306 |