Complex classes like JobProxy 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 JobProxy, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 25 | class JobProxy extends AbstractIdentifiableModificationDateAwareEntity implements JobInterface |
||
| 26 | { |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var JobInterface |
||
| 30 | */ |
||
| 31 | protected $job; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var ArrayAccess |
||
| 35 | */ |
||
| 36 | protected $solrResult; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @param JobInterface $job |
||
| 40 | * @param ArrayAccess $solrResult |
||
| 41 | */ |
||
| 42 | public function __construct(JobInterface $job, ArrayAccess $solrResult) |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @see \Jobs\Entity\JobInterface::getApplications() |
||
| 50 | */ |
||
| 51 | public function getApplications() |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @see \Jobs\Entity\JobInterface::getApplyId() |
||
| 58 | */ |
||
| 59 | public function getApplyId() |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @see \Jobs\Entity\JobInterface::getAtsEnabled() |
||
| 66 | */ |
||
| 67 | public function getAtsEnabled() |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @see \Jobs\Entity\JobInterface::getAtsMode() |
||
| 74 | */ |
||
| 75 | public function getAtsMode() |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @see \Jobs\Entity\JobInterface::getCompany() |
||
| 82 | */ |
||
| 83 | public function getCompany() |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @see \Jobs\Entity\JobInterface::getContactEmail() |
||
| 90 | */ |
||
| 91 | public function getContactEmail() |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @see \Jobs\Entity\JobInterface::getDatePublishEnd() |
||
| 98 | */ |
||
| 99 | public function getDatePublishEnd() |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @see \Jobs\Entity\JobInterface::getDatePublishStart() |
||
| 108 | */ |
||
| 109 | public function getDatePublishStart() |
||
| 115 | |||
| 116 | /** |
||
| 117 | * @see \Jobs\Entity\JobInterface::getHistory() |
||
| 118 | */ |
||
| 119 | public function getHistory() |
||
| 124 | |||
| 125 | /** |
||
| 126 | * @see \Jobs\Entity\JobInterface::getLanguage() |
||
| 127 | */ |
||
| 128 | public function getLanguage() |
||
| 132 | |||
| 133 | /** |
||
| 134 | * @see \Jobs\Entity\JobInterface::getLink() |
||
| 135 | */ |
||
| 136 | public function getLink() |
||
| 140 | |||
| 141 | /** |
||
| 142 | * @see \Jobs\Entity\JobInterface::getLocation() |
||
| 143 | */ |
||
| 144 | public function getLocation() |
||
| 165 | |||
| 166 | /** |
||
| 167 | * @see \Jobs\Entity\JobInterface::getLocations() |
||
| 168 | */ |
||
| 169 | public function getLocations() |
||
| 173 | |||
| 174 | /** |
||
| 175 | * @see \Jobs\Entity\JobInterface::getOrganization() |
||
| 176 | */ |
||
| 177 | public function getOrganization() |
||
| 181 | |||
| 182 | /** |
||
| 183 | * @see \Jobs\Entity\JobInterface::getPortals() |
||
| 184 | */ |
||
| 185 | public function getPortals() |
||
| 189 | |||
| 190 | /** |
||
| 191 | * @see \Jobs\Entity\JobInterface::getReference() |
||
| 192 | */ |
||
| 193 | public function getReference() |
||
| 197 | |||
| 198 | /** |
||
| 199 | * @see \Jobs\Entity\JobInterface::getStatus() |
||
| 200 | */ |
||
| 201 | public function getStatus() |
||
| 205 | |||
| 206 | /** |
||
| 207 | * @see \Jobs\Entity\JobInterface::getTermsAccepted() |
||
| 208 | */ |
||
| 209 | public function getTermsAccepted() |
||
| 213 | |||
| 214 | /** |
||
| 215 | * @see \Jobs\Entity\JobInterface::getTitle() |
||
| 216 | */ |
||
| 217 | public function getTitle() |
||
| 221 | |||
| 222 | /** |
||
| 223 | * @see \Jobs\Entity\JobInterface::getUriApply() |
||
| 224 | */ |
||
| 225 | public function getUriApply() |
||
| 229 | |||
| 230 | /** |
||
| 231 | * @see \Jobs\Entity\JobInterface::getUriPublisher() |
||
| 232 | */ |
||
| 233 | public function getUriPublisher() |
||
| 237 | |||
| 238 | /** |
||
| 239 | * @see \Jobs\Entity\JobInterface::getUser() |
||
| 240 | */ |
||
| 241 | public function getUser() |
||
| 245 | |||
| 246 | /** |
||
| 247 | * @see \Jobs\Entity\JobInterface::setApplications() |
||
| 248 | */ |
||
| 249 | public function setApplications(\Doctrine\Common\Collections\Collection $applications) |
||
| 253 | |||
| 254 | /** |
||
| 255 | * @see \Jobs\Entity\JobInterface::setApplyId() |
||
| 256 | */ |
||
| 257 | public function setApplyId($applyId) |
||
| 261 | |||
| 262 | /** |
||
| 263 | * @see \Jobs\Entity\JobInterface::setAtsEnabled() |
||
| 264 | */ |
||
| 265 | public function setAtsEnabled($atsEnabled) |
||
| 269 | |||
| 270 | /** |
||
| 271 | * @see \Jobs\Entity\JobInterface::setAtsMode() |
||
| 272 | */ |
||
| 273 | public function setAtsMode(\Jobs\Entity\AtsMode $mode) |
||
| 277 | |||
| 278 | /** |
||
| 279 | * @see \Jobs\Entity\JobInterface::setCompany() |
||
| 280 | */ |
||
| 281 | public function setCompany($company) |
||
| 285 | |||
| 286 | /** |
||
| 287 | * @see \Jobs\Entity\JobInterface::setContactEmail() |
||
| 288 | */ |
||
| 289 | public function setContactEmail($email) |
||
| 293 | |||
| 294 | /** |
||
| 295 | * @see \Jobs\Entity\JobInterface::setDatePublishEnd() |
||
| 296 | */ |
||
| 297 | public function setDatePublishEnd($datePublishEnd) |
||
| 301 | |||
| 302 | /** |
||
| 303 | * @see \Jobs\Entity\JobInterface::setDatePublishStart() |
||
| 304 | */ |
||
| 305 | public function setDatePublishStart($datePublishStart) |
||
| 309 | |||
| 310 | /** |
||
| 311 | * @see \Jobs\Entity\JobInterface::setHistory() |
||
| 312 | */ |
||
| 313 | public function setHistory(\Doctrine\Common\Collections\Collection $history) |
||
| 317 | |||
| 318 | /** |
||
| 319 | * @see \Jobs\Entity\JobInterface::setLanguage() |
||
| 320 | */ |
||
| 321 | public function setLanguage($language) |
||
| 325 | |||
| 326 | /** |
||
| 327 | * @see \Jobs\Entity\JobInterface::setLink() |
||
| 328 | */ |
||
| 329 | public function setLink($link) |
||
| 333 | |||
| 334 | /** |
||
| 335 | * @see \Jobs\Entity\JobInterface::setLocation() |
||
| 336 | */ |
||
| 337 | public function setLocation($location) |
||
| 341 | |||
| 342 | /** |
||
| 343 | * @see \Jobs\Entity\JobInterface::setLocations() |
||
| 344 | */ |
||
| 345 | public function setLocations($locations) |
||
| 349 | |||
| 350 | /** |
||
| 351 | * @see \Jobs\Entity\JobInterface::setOrganization() |
||
| 352 | */ |
||
| 353 | public function setOrganization(\Organizations\Entity\OrganizationInterface $organization = null) |
||
| 357 | |||
| 358 | /** |
||
| 359 | * @see \Jobs\Entity\JobInterface::setPortals() |
||
| 360 | */ |
||
| 361 | public function setPortals(array $portals) |
||
| 365 | |||
| 366 | /** |
||
| 367 | * @see \Jobs\Entity\JobInterface::setReference() |
||
| 368 | */ |
||
| 369 | public function setReference($reference) |
||
| 373 | |||
| 374 | /** |
||
| 375 | * @see \Jobs\Entity\JobInterface::setStatus() |
||
| 376 | */ |
||
| 377 | public function setStatus($status) |
||
| 381 | |||
| 382 | /** |
||
| 383 | * @see \Jobs\Entity\JobInterface::setTermsAccepted() |
||
| 384 | */ |
||
| 385 | public function setTermsAccepted($flag) |
||
| 389 | |||
| 390 | /** |
||
| 391 | * @see \Jobs\Entity\JobInterface::setTitle() |
||
| 392 | */ |
||
| 393 | public function setTitle($title) |
||
| 397 | |||
| 398 | /** |
||
| 399 | * @see \Jobs\Entity\JobInterface::setUriApply() |
||
| 400 | */ |
||
| 401 | public function setUriApply($uriApply) |
||
| 405 | |||
| 406 | /** |
||
| 407 | * @see \Jobs\Entity\JobInterface::setUriPublisher() |
||
| 408 | */ |
||
| 409 | public function setUriPublisher($uriPublisher) |
||
| 413 | |||
| 414 | /** |
||
| 415 | * @see \Jobs\Entity\JobInterface::setUser() |
||
| 416 | */ |
||
| 417 | public function setUser(\Auth\Entity\UserInterface $user) |
||
| 421 | |||
| 422 | /** |
||
| 423 | * @see \Zend\Permissions\Acl\Resource\ResourceInterface::getResourceId() |
||
| 424 | */ |
||
| 425 | public function getResourceId() |
||
| 429 | |||
| 430 | /** |
||
| 431 | * @see \Core\Entity\PermissionsAwareInterface::getPermissions() |
||
| 432 | */ |
||
| 433 | public function getPermissions() |
||
| 437 | |||
| 438 | /** |
||
| 439 | * @see \Core\Entity\PermissionsAwareInterface::setPermissions() |
||
| 440 | */ |
||
| 441 | public function setPermissions(\Core\Entity\PermissionsInterface $permissions) |
||
| 445 | |||
| 446 | /** |
||
| 447 | * @param string $key |
||
| 448 | * @return mixed |
||
| 449 | */ |
||
| 450 | protected function getSolrResultValue($key) |
||
| 454 | } |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.