Complex classes like EmptyUser 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 EmptyUser, and based on these observations, apply Extract Interface, too.
| 1 | <?php declare(strict_types=1); |
||
| 8 | abstract class EmptyUser implements UserInterface, EmptyResourceInterface |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @return int |
||
| 12 | */ |
||
| 13 | 2 | public function id() : int |
|
| 17 | |||
| 18 | /** |
||
| 19 | * @return string |
||
| 20 | */ |
||
| 21 | 2 | public function idStr() : string |
|
| 25 | |||
| 26 | /** |
||
| 27 | * @return string |
||
| 28 | */ |
||
| 29 | 2 | public function name() : string |
|
| 33 | |||
| 34 | /** |
||
| 35 | * @return string |
||
| 36 | */ |
||
| 37 | 2 | public function screenName() : string |
|
| 41 | |||
| 42 | /** |
||
| 43 | * @return string |
||
| 44 | */ |
||
| 45 | 2 | public function location() : string |
|
| 49 | |||
| 50 | /** |
||
| 51 | * @return string |
||
| 52 | */ |
||
| 53 | 2 | public function profileLocation() : string |
|
| 57 | |||
| 58 | /** |
||
| 59 | * @return string |
||
| 60 | */ |
||
| 61 | 2 | public function description() : string |
|
| 65 | |||
| 66 | /** |
||
| 67 | * @return string |
||
| 68 | */ |
||
| 69 | 2 | public function url() : string |
|
| 73 | |||
| 74 | /** |
||
| 75 | * @return bool |
||
| 76 | */ |
||
| 77 | 2 | public function protected() : bool |
|
| 81 | |||
| 82 | /** |
||
| 83 | * @return int |
||
| 84 | */ |
||
| 85 | 2 | public function followersCount() : int |
|
| 89 | |||
| 90 | /** |
||
| 91 | * @return int |
||
| 92 | */ |
||
| 93 | 2 | public function friendsCount() : int |
|
| 97 | |||
| 98 | /** |
||
| 99 | * @return int |
||
| 100 | */ |
||
| 101 | 2 | public function listedCount() : int |
|
| 105 | |||
| 106 | /** |
||
| 107 | * @return DateTime |
||
| 108 | */ |
||
| 109 | 2 | public function createdAt() : DateTime |
|
| 113 | |||
| 114 | /** |
||
| 115 | * @return int |
||
| 116 | */ |
||
| 117 | 2 | public function favouritesCount() : int |
|
| 121 | |||
| 122 | /** |
||
| 123 | * @return int |
||
| 124 | */ |
||
| 125 | 2 | public function utcOffset() : int |
|
| 129 | |||
| 130 | /** |
||
| 131 | * @return string |
||
| 132 | */ |
||
| 133 | 2 | public function timeZone() : string |
|
| 137 | |||
| 138 | /** |
||
| 139 | * @return bool |
||
| 140 | */ |
||
| 141 | 2 | public function geoEnabled() : bool |
|
| 145 | |||
| 146 | /** |
||
| 147 | * @return bool |
||
| 148 | */ |
||
| 149 | 2 | public function verified() : bool |
|
| 153 | |||
| 154 | /** |
||
| 155 | * @return int |
||
| 156 | */ |
||
| 157 | 2 | public function statusesCount() : int |
|
| 161 | |||
| 162 | /** |
||
| 163 | * @return string |
||
| 164 | */ |
||
| 165 | 2 | public function lang() : string |
|
| 169 | |||
| 170 | /** |
||
| 171 | * @return array |
||
| 172 | */ |
||
| 173 | 2 | public function status() : array |
|
| 177 | |||
| 178 | /** |
||
| 179 | * @return bool |
||
| 180 | */ |
||
| 181 | 2 | public function contributorsEnabled() : bool |
|
| 185 | |||
| 186 | /** |
||
| 187 | * @return bool |
||
| 188 | */ |
||
| 189 | 2 | public function isTranslator() : bool |
|
| 193 | |||
| 194 | /** |
||
| 195 | * @return bool |
||
| 196 | */ |
||
| 197 | 2 | public function isTranslatorEnabled() : bool |
|
| 201 | |||
| 202 | /** |
||
| 203 | * @return string |
||
| 204 | */ |
||
| 205 | 2 | public function profileBackgroundColor() : string |
|
| 209 | |||
| 210 | /** |
||
| 211 | * @return string |
||
| 212 | */ |
||
| 213 | 2 | public function profileBackgroundImageUrl() : string |
|
| 217 | |||
| 218 | /** |
||
| 219 | * @return string |
||
| 220 | */ |
||
| 221 | 2 | public function profileBackgroundImageUrlHttps() : string |
|
| 225 | |||
| 226 | /** |
||
| 227 | * @return bool |
||
| 228 | */ |
||
| 229 | 2 | public function profileBackgroundTile() : bool |
|
| 233 | |||
| 234 | /** |
||
| 235 | * @return string |
||
| 236 | */ |
||
| 237 | 2 | public function profileImageUrl() : string |
|
| 241 | |||
| 242 | /** |
||
| 243 | * @return string |
||
| 244 | */ |
||
| 245 | 2 | public function profileImageUrlHttps() : string |
|
| 249 | |||
| 250 | /** |
||
| 251 | * @return string |
||
| 252 | */ |
||
| 253 | 2 | public function profileBannerUrl() : string |
|
| 257 | |||
| 258 | /** |
||
| 259 | * @return string |
||
| 260 | */ |
||
| 261 | 2 | public function profileLinkColor() : string |
|
| 265 | |||
| 266 | /** |
||
| 267 | * @return string |
||
| 268 | */ |
||
| 269 | 2 | public function profileSidebarBorderColor() : string |
|
| 273 | |||
| 274 | /** |
||
| 275 | * @return string |
||
| 276 | */ |
||
| 277 | 2 | public function profileSidebarFillColor() : string |
|
| 281 | |||
| 282 | /** |
||
| 283 | * @return string |
||
| 284 | */ |
||
| 285 | 2 | public function profileTextColor() : string |
|
| 289 | |||
| 290 | /** |
||
| 291 | * @return bool |
||
| 292 | */ |
||
| 293 | 2 | public function profileUseBackgroundImage() : bool |
|
| 297 | |||
| 298 | /** |
||
| 299 | * @return bool |
||
| 300 | */ |
||
| 301 | 2 | public function hasExtendedProfile() : bool |
|
| 305 | |||
| 306 | /** |
||
| 307 | * @return bool |
||
| 308 | */ |
||
| 309 | 2 | public function defaultProfile() : bool |
|
| 313 | |||
| 314 | /** |
||
| 315 | * @return bool |
||
| 316 | */ |
||
| 317 | 2 | public function defaultProfileImage() : bool |
|
| 321 | |||
| 322 | /** |
||
| 323 | * @return bool |
||
| 324 | */ |
||
| 325 | 2 | public function following() : bool |
|
| 329 | |||
| 330 | /** |
||
| 331 | * @return bool |
||
| 332 | */ |
||
| 333 | 2 | public function followRequestSent() : bool |
|
| 337 | |||
| 338 | /** |
||
| 339 | * @return bool |
||
| 340 | */ |
||
| 341 | 2 | public function notifications() : bool |
|
| 345 | |||
| 346 | /** |
||
| 347 | * @return string |
||
| 348 | */ |
||
| 349 | 2 | public function translatorType() : string |
|
| 353 | } |
||
| 354 |