Complex classes like Taches 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 Taches, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 20 | class Taches { |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Article. |
||
| 24 | * |
||
| 25 | * @var string|null |
||
| 26 | */ |
||
| 27 | private $article; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Code. |
||
| 31 | * |
||
| 32 | * @var string|null |
||
| 33 | */ |
||
| 34 | private $code; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Code frais. |
||
| 38 | * |
||
| 39 | * @var string|null |
||
| 40 | */ |
||
| 41 | private $codeFrais; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Code regroupement. |
||
| 45 | * |
||
| 46 | * @var string|null |
||
| 47 | */ |
||
| 48 | private $codeRegroupement; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Code travail. |
||
| 52 | * |
||
| 53 | * @var string|null |
||
| 54 | */ |
||
| 55 | private $codeTravail; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Code uo. |
||
| 59 | * |
||
| 60 | * @var string|null |
||
| 61 | */ |
||
| 62 | private $codeUo; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Compte comptable. |
||
| 66 | * |
||
| 67 | * @var string|null |
||
| 68 | */ |
||
| 69 | private $compteComptable; |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Compte tva. |
||
| 73 | * |
||
| 74 | * @var string|null |
||
| 75 | */ |
||
| 76 | private $compteTva; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Facturable. |
||
| 80 | * |
||
| 81 | * @var bool|null |
||
| 82 | */ |
||
| 83 | private $facturable; |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Inactif. |
||
| 87 | * |
||
| 88 | * @var bool|null |
||
| 89 | */ |
||
| 90 | private $inactif; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * Intitule. |
||
| 94 | * |
||
| 95 | * @var string|null |
||
| 96 | */ |
||
| 97 | private $intitule; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Intitule rtf. |
||
| 101 | * |
||
| 102 | * @var string|null |
||
| 103 | */ |
||
| 104 | private $intituleRtf; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Liste travaux. |
||
| 108 | * |
||
| 109 | * @var string|null |
||
| 110 | */ |
||
| 111 | private $listeTravaux; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * Niveau exec. |
||
| 115 | * |
||
| 116 | * @var string|null |
||
| 117 | */ |
||
| 118 | private $niveauExec; |
||
| 119 | |||
| 120 | /** |
||
| 121 | * Non remboursable. |
||
| 122 | * |
||
| 123 | * @var bool|null |
||
| 124 | */ |
||
| 125 | private $nonRemboursable; |
||
| 126 | |||
| 127 | /** |
||
| 128 | * Non travaillee. |
||
| 129 | * |
||
| 130 | * @var bool|null |
||
| 131 | */ |
||
| 132 | private $nonTravaillee; |
||
| 133 | |||
| 134 | /** |
||
| 135 | * Operationnelle. |
||
| 136 | * |
||
| 137 | * @var bool|null |
||
| 138 | */ |
||
| 139 | private $operationnelle; |
||
| 140 | |||
| 141 | /** |
||
| 142 | * Prix vente1. |
||
| 143 | * |
||
| 144 | * @var float|null |
||
| 145 | */ |
||
| 146 | private $prixVente1; |
||
| 147 | |||
| 148 | /** |
||
| 149 | * Prix vente2. |
||
| 150 | * |
||
| 151 | * @var float|null |
||
| 152 | */ |
||
| 153 | private $prixVente2; |
||
| 154 | |||
| 155 | /** |
||
| 156 | * Prix vente3. |
||
| 157 | * |
||
| 158 | * @var float|null |
||
| 159 | */ |
||
| 160 | private $prixVente3; |
||
| 161 | |||
| 162 | /** |
||
| 163 | * Pv maxi. |
||
| 164 | * |
||
| 165 | * @var float|null |
||
| 166 | */ |
||
| 167 | private $pvMaxi; |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Saisie tva. |
||
| 171 | * |
||
| 172 | * @var bool|null |
||
| 173 | */ |
||
| 174 | private $saisieTva; |
||
| 175 | |||
| 176 | /** |
||
| 177 | * Super facturable. |
||
| 178 | * |
||
| 179 | * @var bool|null |
||
| 180 | */ |
||
| 181 | private $superFacturable; |
||
| 182 | |||
| 183 | /** |
||
| 184 | * Ticket resto. |
||
| 185 | * |
||
| 186 | * @var bool|null |
||
| 187 | */ |
||
| 188 | private $ticketResto; |
||
| 189 | |||
| 190 | /** |
||
| 191 | * Type heure. |
||
| 192 | * |
||
| 193 | * @var string|null |
||
| 194 | */ |
||
| 195 | private $typeHeure; |
||
| 196 | |||
| 197 | /** |
||
| 198 | * Constructor. |
||
| 199 | */ |
||
| 200 | public function __construct() { |
||
| 203 | |||
| 204 | /** |
||
| 205 | * Get the article. |
||
| 206 | * |
||
| 207 | * @return string|null Returns the article. |
||
| 208 | */ |
||
| 209 | public function getArticle(): ?string { |
||
| 212 | |||
| 213 | /** |
||
| 214 | * Get the code. |
||
| 215 | * |
||
| 216 | * @return string|null Returns the code. |
||
| 217 | */ |
||
| 218 | public function getCode(): ?string { |
||
| 221 | |||
| 222 | /** |
||
| 223 | * Get the code frais. |
||
| 224 | * |
||
| 225 | * @return string|null Returns the code frais. |
||
| 226 | */ |
||
| 227 | public function getCodeFrais(): ?string { |
||
| 230 | |||
| 231 | /** |
||
| 232 | * Get the code regroupement. |
||
| 233 | * |
||
| 234 | * @return string|null Returns the code regroupement. |
||
| 235 | */ |
||
| 236 | public function getCodeRegroupement(): ?string { |
||
| 239 | |||
| 240 | /** |
||
| 241 | * Get the code travail. |
||
| 242 | * |
||
| 243 | * @return string|null Returns the code travail. |
||
| 244 | */ |
||
| 245 | public function getCodeTravail(): ?string { |
||
| 248 | |||
| 249 | /** |
||
| 250 | * Get the code uo. |
||
| 251 | * |
||
| 252 | * @return string|null Returns the code uo. |
||
| 253 | */ |
||
| 254 | public function getCodeUo(): ?string { |
||
| 257 | |||
| 258 | /** |
||
| 259 | * Get the compte comptable. |
||
| 260 | * |
||
| 261 | * @return string|null Returns the compte comptable. |
||
| 262 | */ |
||
| 263 | public function getCompteComptable(): ?string { |
||
| 266 | |||
| 267 | /** |
||
| 268 | * Get the compte tva. |
||
| 269 | * |
||
| 270 | * @return string|null Returns the compte tva. |
||
| 271 | */ |
||
| 272 | public function getCompteTva(): ?string { |
||
| 275 | |||
| 276 | /** |
||
| 277 | * Get the facturable. |
||
| 278 | * |
||
| 279 | * @return bool|null Returns the facturable. |
||
| 280 | */ |
||
| 281 | public function getFacturable(): ?bool { |
||
| 284 | |||
| 285 | /** |
||
| 286 | * Get the inactif. |
||
| 287 | * |
||
| 288 | * @return bool|null Returns the inactif. |
||
| 289 | */ |
||
| 290 | public function getInactif(): ?bool { |
||
| 293 | |||
| 294 | /** |
||
| 295 | * Get the intitule. |
||
| 296 | * |
||
| 297 | * @return string|null Returns the intitule. |
||
| 298 | */ |
||
| 299 | public function getIntitule(): ?string { |
||
| 302 | |||
| 303 | /** |
||
| 304 | * Get the intitule rtf. |
||
| 305 | * |
||
| 306 | * @return string|null Returns the intitule rtf. |
||
| 307 | */ |
||
| 308 | public function getIntituleRtf(): ?string { |
||
| 311 | |||
| 312 | /** |
||
| 313 | * Get the liste travaux. |
||
| 314 | * |
||
| 315 | * @return string|null Returns the liste travaux. |
||
| 316 | */ |
||
| 317 | public function getListeTravaux(): ?string { |
||
| 320 | |||
| 321 | /** |
||
| 322 | * Get the niveau exec. |
||
| 323 | * |
||
| 324 | * @return string|null Returns the niveau exec. |
||
| 325 | */ |
||
| 326 | public function getNiveauExec(): ?string { |
||
| 329 | |||
| 330 | /** |
||
| 331 | * Get the non remboursable. |
||
| 332 | * |
||
| 333 | * @return bool|null Returns the non remboursable. |
||
| 334 | */ |
||
| 335 | public function getNonRemboursable(): ?bool { |
||
| 338 | |||
| 339 | /** |
||
| 340 | * Get the non travaillee. |
||
| 341 | * |
||
| 342 | * @return bool|null Returns the non travaillee. |
||
| 343 | */ |
||
| 344 | public function getNonTravaillee(): ?bool { |
||
| 347 | |||
| 348 | /** |
||
| 349 | * Get the operationnelle. |
||
| 350 | * |
||
| 351 | * @return bool|null Returns the operationnelle. |
||
| 352 | */ |
||
| 353 | public function getOperationnelle(): ?bool { |
||
| 356 | |||
| 357 | /** |
||
| 358 | * Get the prix vente1. |
||
| 359 | * |
||
| 360 | * @return float|null Returns the prix vente1. |
||
| 361 | */ |
||
| 362 | public function getPrixVente1(): ?float { |
||
| 365 | |||
| 366 | /** |
||
| 367 | * Get the prix vente2. |
||
| 368 | * |
||
| 369 | * @return float|null Returns the prix vente2. |
||
| 370 | */ |
||
| 371 | public function getPrixVente2(): ?float { |
||
| 374 | |||
| 375 | /** |
||
| 376 | * Get the prix vente3. |
||
| 377 | * |
||
| 378 | * @return float|null Returns the prix vente3. |
||
| 379 | */ |
||
| 380 | public function getPrixVente3(): ?float { |
||
| 383 | |||
| 384 | /** |
||
| 385 | * Get the pv maxi. |
||
| 386 | * |
||
| 387 | * @return float|null Returns the pv maxi. |
||
| 388 | */ |
||
| 389 | public function getPvMaxi(): ?float { |
||
| 392 | |||
| 393 | /** |
||
| 394 | * Get the saisie tva. |
||
| 395 | * |
||
| 396 | * @return bool|null Returns the saisie tva. |
||
| 397 | */ |
||
| 398 | public function getSaisieTva(): ?bool { |
||
| 401 | |||
| 402 | /** |
||
| 403 | * Get the super facturable. |
||
| 404 | * |
||
| 405 | * @return bool|null Returns the super facturable. |
||
| 406 | */ |
||
| 407 | public function getSuperFacturable(): ?bool { |
||
| 410 | |||
| 411 | /** |
||
| 412 | * Get the ticket resto. |
||
| 413 | * |
||
| 414 | * @return bool|null Returns the ticket resto. |
||
| 415 | */ |
||
| 416 | public function getTicketResto(): ?bool { |
||
| 419 | |||
| 420 | /** |
||
| 421 | * Get the type heure. |
||
| 422 | * |
||
| 423 | * @return string|null Returns the type heure. |
||
| 424 | */ |
||
| 425 | public function getTypeHeure(): ?string { |
||
| 428 | |||
| 429 | /** |
||
| 430 | * Set the article. |
||
| 431 | * |
||
| 432 | * @param string|null $article The article. |
||
| 433 | * @return Taches Returns this Taches. |
||
| 434 | */ |
||
| 435 | public function setArticle(?string $article): Taches { |
||
| 439 | |||
| 440 | /** |
||
| 441 | * Set the code. |
||
| 442 | * |
||
| 443 | * @param string|null $code The code. |
||
| 444 | * @return Taches Returns this Taches. |
||
| 445 | */ |
||
| 446 | public function setCode(?string $code): Taches { |
||
| 450 | |||
| 451 | /** |
||
| 452 | * Set the code frais. |
||
| 453 | * |
||
| 454 | * @param string|null $codeFrais The code frais. |
||
| 455 | * @return Taches Returns this Taches. |
||
| 456 | */ |
||
| 457 | public function setCodeFrais(?string $codeFrais): Taches { |
||
| 461 | |||
| 462 | /** |
||
| 463 | * Set the code regroupement. |
||
| 464 | * |
||
| 465 | * @param string|null $codeRegroupement The code regroupement. |
||
| 466 | * @return Taches Returns this Taches. |
||
| 467 | */ |
||
| 468 | public function setCodeRegroupement(?string $codeRegroupement): Taches { |
||
| 472 | |||
| 473 | /** |
||
| 474 | * Set the code travail. |
||
| 475 | * |
||
| 476 | * @param string|null $codeTravail The code travail. |
||
| 477 | * @return Taches Returns this Taches. |
||
| 478 | */ |
||
| 479 | public function setCodeTravail(?string $codeTravail): Taches { |
||
| 483 | |||
| 484 | /** |
||
| 485 | * Set the code uo. |
||
| 486 | * |
||
| 487 | * @param string|null $codeUo The code uo. |
||
| 488 | * @return Taches Returns this Taches. |
||
| 489 | */ |
||
| 490 | public function setCodeUo(?string $codeUo): Taches { |
||
| 494 | |||
| 495 | /** |
||
| 496 | * Set the compte comptable. |
||
| 497 | * |
||
| 498 | * @param string|null $compteComptable The compte comptable. |
||
| 499 | * @return Taches Returns this Taches. |
||
| 500 | */ |
||
| 501 | public function setCompteComptable(?string $compteComptable): Taches { |
||
| 505 | |||
| 506 | /** |
||
| 507 | * Set the compte tva. |
||
| 508 | * |
||
| 509 | * @param string|null $compteTva The compte tva. |
||
| 510 | * @return Taches Returns this Taches. |
||
| 511 | */ |
||
| 512 | public function setCompteTva(?string $compteTva): Taches { |
||
| 516 | |||
| 517 | /** |
||
| 518 | * Set the facturable. |
||
| 519 | * |
||
| 520 | * @param bool|null $facturable The facturable. |
||
| 521 | * @return Taches Returns this Taches. |
||
| 522 | */ |
||
| 523 | public function setFacturable(?bool $facturable): Taches { |
||
| 527 | |||
| 528 | /** |
||
| 529 | * Set the inactif. |
||
| 530 | * |
||
| 531 | * @param bool|null $inactif The inactif. |
||
| 532 | * @return Taches Returns this Taches. |
||
| 533 | */ |
||
| 534 | public function setInactif(?bool $inactif): Taches { |
||
| 538 | |||
| 539 | /** |
||
| 540 | * Set the intitule. |
||
| 541 | * |
||
| 542 | * @param string|null $intitule The intitule. |
||
| 543 | * @return Taches Returns this Taches. |
||
| 544 | */ |
||
| 545 | public function setIntitule(?string $intitule): Taches { |
||
| 549 | |||
| 550 | /** |
||
| 551 | * Set the intitule rtf. |
||
| 552 | * |
||
| 553 | * @param string|null $intituleRtf The intitule rtf. |
||
| 554 | * @return Taches Returns this Taches. |
||
| 555 | */ |
||
| 556 | public function setIntituleRtf(?string $intituleRtf): Taches { |
||
| 560 | |||
| 561 | /** |
||
| 562 | * Set the liste travaux. |
||
| 563 | * |
||
| 564 | * @param string|null $listeTravaux The liste travaux. |
||
| 565 | * @return Taches Returns this Taches. |
||
| 566 | */ |
||
| 567 | public function setListeTravaux(?string $listeTravaux): Taches { |
||
| 571 | |||
| 572 | /** |
||
| 573 | * Set the niveau exec. |
||
| 574 | * |
||
| 575 | * @param string|null $niveauExec The niveau exec. |
||
| 576 | * @return Taches Returns this Taches. |
||
| 577 | */ |
||
| 578 | public function setNiveauExec(?string $niveauExec): Taches { |
||
| 582 | |||
| 583 | /** |
||
| 584 | * Set the non remboursable. |
||
| 585 | * |
||
| 586 | * @param bool|null $nonRemboursable The non remboursable. |
||
| 587 | * @return Taches Returns this Taches. |
||
| 588 | */ |
||
| 589 | public function setNonRemboursable(?bool $nonRemboursable): Taches { |
||
| 593 | |||
| 594 | /** |
||
| 595 | * Set the non travaillee. |
||
| 596 | * |
||
| 597 | * @param bool|null $nonTravaillee The non travaillee. |
||
| 598 | * @return Taches Returns this Taches. |
||
| 599 | */ |
||
| 600 | public function setNonTravaillee(?bool $nonTravaillee): Taches { |
||
| 604 | |||
| 605 | /** |
||
| 606 | * Set the operationnelle. |
||
| 607 | * |
||
| 608 | * @param bool|null $operationnelle The operationnelle. |
||
| 609 | * @return Taches Returns this Taches. |
||
| 610 | */ |
||
| 611 | public function setOperationnelle(?bool $operationnelle): Taches { |
||
| 615 | |||
| 616 | /** |
||
| 617 | * Set the prix vente1. |
||
| 618 | * |
||
| 619 | * @param float|null $prixVente1 The prix vente1. |
||
| 620 | * @return Taches Returns this Taches. |
||
| 621 | */ |
||
| 622 | public function setPrixVente1(?float $prixVente1): Taches { |
||
| 626 | |||
| 627 | /** |
||
| 628 | * Set the prix vente2. |
||
| 629 | * |
||
| 630 | * @param float|null $prixVente2 The prix vente2. |
||
| 631 | * @return Taches Returns this Taches. |
||
| 632 | */ |
||
| 633 | public function setPrixVente2(?float $prixVente2): Taches { |
||
| 637 | |||
| 638 | /** |
||
| 639 | * Set the prix vente3. |
||
| 640 | * |
||
| 641 | * @param float|null $prixVente3 The prix vente3. |
||
| 642 | * @return Taches Returns this Taches. |
||
| 643 | */ |
||
| 644 | public function setPrixVente3(?float $prixVente3): Taches { |
||
| 648 | |||
| 649 | /** |
||
| 650 | * Set the pv maxi. |
||
| 651 | * |
||
| 652 | * @param float|null $pvMaxi The pv maxi. |
||
| 653 | * @return Taches Returns this Taches. |
||
| 654 | */ |
||
| 655 | public function setPvMaxi(?float $pvMaxi): Taches { |
||
| 659 | |||
| 660 | /** |
||
| 661 | * Set the saisie tva. |
||
| 662 | * |
||
| 663 | * @param bool|null $saisieTva The saisie tva. |
||
| 664 | * @return Taches Returns this Taches. |
||
| 665 | */ |
||
| 666 | public function setSaisieTva(?bool $saisieTva): Taches { |
||
| 670 | |||
| 671 | /** |
||
| 672 | * Set the super facturable. |
||
| 673 | * |
||
| 674 | * @param bool|null $superFacturable The super facturable. |
||
| 675 | * @return Taches Returns this Taches. |
||
| 676 | */ |
||
| 677 | public function setSuperFacturable(?bool $superFacturable): Taches { |
||
| 681 | |||
| 682 | /** |
||
| 683 | * Set the ticket resto. |
||
| 684 | * |
||
| 685 | * @param bool|null $ticketResto The ticket resto. |
||
| 686 | * @return Taches Returns this Taches. |
||
| 687 | */ |
||
| 688 | public function setTicketResto(?bool $ticketResto): Taches { |
||
| 692 | |||
| 693 | /** |
||
| 694 | * Set the type heure. |
||
| 695 | * |
||
| 696 | * @param string|null $typeHeure The type heure. |
||
| 697 | * @return Taches Returns this Taches. |
||
| 698 | */ |
||
| 699 | public function setTypeHeure(?string $typeHeure): Taches { |
||
| 703 | } |
||
| 704 |