Complex classes like Board 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 Board, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 10 | class Board extends AbstractObject implements BoardInterface |
||
| 11 | { |
||
| 12 | protected $apiName = 'board'; |
||
| 13 | |||
| 14 | protected $loadParams = array( |
||
| 15 | 'fields' => 'all', |
||
| 16 | 'organization' => true, |
||
| 17 | 'organization_memberships' => 'all', |
||
| 18 | 'members' => 'all', |
||
| 19 | 'membersInvited' => 'all', |
||
| 20 | 'memberships' => 'all', |
||
| 21 | 'lists' => 'all', |
||
| 22 | 'labels' => 'all', |
||
| 23 | ); |
||
| 24 | |||
| 25 | /** |
||
| 26 | * {@inheritdoc} |
||
| 27 | */ |
||
| 28 | public function setName($name) |
||
| 34 | |||
| 35 | /** |
||
| 36 | * {@inheritdoc} |
||
| 37 | */ |
||
| 38 | public function getName() |
||
| 42 | |||
| 43 | /** |
||
| 44 | * {@inheritdoc} |
||
| 45 | */ |
||
| 46 | public function setDescription($desc) |
||
| 52 | |||
| 53 | /** |
||
| 54 | * {@inheritdoc} |
||
| 55 | */ |
||
| 56 | public function getDescription() |
||
| 60 | |||
| 61 | /** |
||
| 62 | * {@inheritdoc} |
||
| 63 | */ |
||
| 64 | public function getDescriptionData() |
||
| 68 | |||
| 69 | /** |
||
| 70 | * {@inheritdoc} |
||
| 71 | */ |
||
| 72 | public function getUrl() |
||
| 76 | |||
| 77 | /** |
||
| 78 | * {@inheritdoc} |
||
| 79 | */ |
||
| 80 | public function getShortUrl() |
||
| 84 | |||
| 85 | /** |
||
| 86 | * {@inheritdoc} |
||
| 87 | */ |
||
| 88 | public function getShortLink() |
||
| 92 | |||
| 93 | /** |
||
| 94 | * {@inheritdoc} |
||
| 95 | */ |
||
| 96 | public function setOrganizationId($organizationId) |
||
| 102 | |||
| 103 | /** |
||
| 104 | * {@inheritdoc} |
||
| 105 | */ |
||
| 106 | public function getOrganizationId() |
||
| 110 | |||
| 111 | /** |
||
| 112 | * {@inheritdoc} |
||
| 113 | */ |
||
| 114 | public function setOrganization(OrganizationInterface $organization) |
||
| 118 | |||
| 119 | /** |
||
| 120 | * {@inheritdoc} |
||
| 121 | */ |
||
| 122 | public function getOrganization() |
||
| 126 | |||
| 127 | /** |
||
| 128 | * {@inheritdoc} |
||
| 129 | */ |
||
| 130 | public function getLists() |
||
| 140 | |||
| 141 | /** |
||
| 142 | * {@inheritdoc} |
||
| 143 | */ |
||
| 144 | public function getList($idOrName) |
||
| 158 | |||
| 159 | /** |
||
| 160 | * {@inheritdoc} |
||
| 161 | */ |
||
| 162 | public function setClosed($closed) |
||
| 168 | |||
| 169 | /** |
||
| 170 | * {@inheritdoc} |
||
| 171 | */ |
||
| 172 | public function isClosed() |
||
| 176 | |||
| 177 | /** |
||
| 178 | * {@inheritdoc} |
||
| 179 | */ |
||
| 180 | public function setPinned($pinned) |
||
| 186 | |||
| 187 | /** |
||
| 188 | * {@inheritdoc} |
||
| 189 | */ |
||
| 190 | public function isPinned() |
||
| 194 | |||
| 195 | /** |
||
| 196 | * {@inheritdoc} |
||
| 197 | */ |
||
| 198 | public function setStarred($starred) |
||
| 204 | |||
| 205 | /** |
||
| 206 | * {@inheritdoc} |
||
| 207 | */ |
||
| 208 | public function isStarred() |
||
| 212 | |||
| 213 | /** |
||
| 214 | * {@inheritdoc} |
||
| 215 | */ |
||
| 216 | public function setSubscribed($subscribed) |
||
| 222 | |||
| 223 | /** |
||
| 224 | * {@inheritdoc} |
||
| 225 | */ |
||
| 226 | public function isSubscribed() |
||
| 230 | |||
| 231 | /** |
||
| 232 | * {@inheritdoc} |
||
| 233 | */ |
||
| 234 | public function isInvited() |
||
| 238 | |||
| 239 | /** |
||
| 240 | * {@inheritdoc} |
||
| 241 | */ |
||
| 242 | public function setRequiredRoleToInvite($role) |
||
| 248 | |||
| 249 | /** |
||
| 250 | * {@inheritdoc} |
||
| 251 | */ |
||
| 252 | public function getRequiredRoleToInvite() |
||
| 256 | |||
| 257 | /** |
||
| 258 | * {@inheritdoc} |
||
| 259 | */ |
||
| 260 | public function setMemberships(array $memberships) |
||
| 266 | |||
| 267 | /** |
||
| 268 | * {@inheritdoc} |
||
| 269 | */ |
||
| 270 | public function getMemberships() |
||
| 274 | |||
| 275 | /** |
||
| 276 | * {@inheritdoc} |
||
| 277 | */ |
||
| 278 | public function setPreferences(array $prefs) |
||
| 284 | |||
| 285 | /** |
||
| 286 | * {@inheritdoc} |
||
| 287 | */ |
||
| 288 | public function getPreferences() |
||
| 292 | |||
| 293 | /** |
||
| 294 | * {@inheritdoc} |
||
| 295 | */ |
||
| 296 | public function setLabelNames(array $labelNames) |
||
| 302 | |||
| 303 | /** |
||
| 304 | * {@inheritdoc} |
||
| 305 | */ |
||
| 306 | public function getLabelNames() |
||
| 310 | |||
| 311 | /** |
||
| 312 | * {@inheritdoc} |
||
| 313 | */ |
||
| 314 | public function getLabels() |
||
| 324 | |||
| 325 | public function getLabel($name, $color) |
||
| 340 | |||
| 341 | /** |
||
| 342 | * {@inheritdoc} |
||
| 343 | */ |
||
| 344 | public function setPowerUps(array $powerUps) |
||
| 350 | |||
| 351 | /** |
||
| 352 | * {@inheritdoc} |
||
| 353 | */ |
||
| 354 | public function getPowerUps() |
||
| 358 | |||
| 359 | /** |
||
| 360 | * {@inheritdoc} |
||
| 361 | */ |
||
| 362 | public function getDateOfLastActivity() |
||
| 366 | |||
| 367 | /** |
||
| 368 | * {@inheritdoc} |
||
| 369 | */ |
||
| 370 | public function getDateOfLastView() |
||
| 374 | } |
||
| 375 |