| Total Complexity | 42 |
| Total Lines | 654 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like CGroupInfo 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.
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 CGroupInfo, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 23 | class CGroupInfo |
||
| 24 | { |
||
| 25 | use CourseTrait; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var int |
||
| 29 | * |
||
| 30 | * @ORM\Column(name="iid", type="integer") |
||
| 31 | * @ORM\Id |
||
| 32 | * @ORM\GeneratedValue |
||
| 33 | */ |
||
| 34 | protected $iid; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var int |
||
| 38 | * |
||
| 39 | * @ORM\Column(name="id", type="integer", nullable=true) |
||
| 40 | */ |
||
| 41 | protected $id; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @var string |
||
| 45 | * |
||
| 46 | * @ORM\Column(name="name", type="string", length=100, nullable=true) |
||
| 47 | */ |
||
| 48 | protected $name; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @var bool |
||
| 52 | * |
||
| 53 | * @ORM\Column(name="status", type="boolean", nullable=true) |
||
| 54 | */ |
||
| 55 | protected $status; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @var int |
||
| 59 | * |
||
| 60 | * @ORM\Column(name="category_id", type="integer", nullable=true) |
||
| 61 | */ |
||
| 62 | protected $categoryId; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @var string |
||
| 66 | * |
||
| 67 | * @ORM\Column(name="description", type="text", nullable=true) |
||
| 68 | */ |
||
| 69 | protected $description; |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @var int |
||
| 73 | * |
||
| 74 | * @ORM\Column(name="max_student", type="integer", nullable=false) |
||
| 75 | */ |
||
| 76 | protected $maxStudent; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @var bool |
||
| 80 | * |
||
| 81 | * @ORM\Column(name="doc_state", type="boolean", nullable=false) |
||
| 82 | */ |
||
| 83 | protected $docState; |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @var bool |
||
| 87 | * |
||
| 88 | * @ORM\Column(name="calendar_state", type="boolean", nullable=false) |
||
| 89 | */ |
||
| 90 | protected $calendarState; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @var bool |
||
| 94 | * |
||
| 95 | * @ORM\Column(name="work_state", type="boolean", nullable=false) |
||
| 96 | */ |
||
| 97 | protected $workState; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * @var bool |
||
| 101 | * |
||
| 102 | * @ORM\Column(name="announcements_state", type="boolean", nullable=false) |
||
| 103 | */ |
||
| 104 | protected $announcementsState; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @var bool |
||
| 108 | * |
||
| 109 | * @ORM\Column(name="forum_state", type="boolean", nullable=false) |
||
| 110 | */ |
||
| 111 | protected $forumState; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @var bool |
||
| 115 | * |
||
| 116 | * @ORM\Column(name="wiki_state", type="boolean", nullable=false) |
||
| 117 | */ |
||
| 118 | protected $wikiState; |
||
| 119 | |||
| 120 | /** |
||
| 121 | * @var bool |
||
| 122 | * |
||
| 123 | * @ORM\Column(name="chat_state", type="boolean", nullable=false) |
||
| 124 | */ |
||
| 125 | protected $chatState; |
||
| 126 | |||
| 127 | /** |
||
| 128 | * @var string |
||
| 129 | * |
||
| 130 | * @ORM\Column(name="secret_directory", type="string", length=255, nullable=true) |
||
| 131 | */ |
||
| 132 | protected $secretDirectory; |
||
| 133 | |||
| 134 | /** |
||
| 135 | * @var bool |
||
| 136 | * |
||
| 137 | * @ORM\Column(name="self_registration_allowed", type="boolean", nullable=false) |
||
| 138 | */ |
||
| 139 | protected $selfRegistrationAllowed; |
||
| 140 | |||
| 141 | /** |
||
| 142 | * @var bool |
||
| 143 | * |
||
| 144 | * @ORM\Column(name="self_unregistration_allowed", type="boolean", nullable=false) |
||
| 145 | */ |
||
| 146 | protected $selfUnregistrationAllowed; |
||
| 147 | |||
| 148 | /** |
||
| 149 | * @var int |
||
| 150 | * |
||
| 151 | * @ORM\Column(name="session_id", type="integer", nullable=false) |
||
| 152 | */ |
||
| 153 | protected $sessionId; |
||
| 154 | |||
| 155 | /** |
||
| 156 | * @var int |
||
| 157 | * |
||
| 158 | * ORM\Column(name="doc_access", type="integer", nullable=false, options={"default":0}) |
||
| 159 | */ |
||
| 160 | protected $docAccess; |
||
| 161 | |||
| 162 | /** |
||
| 163 | * @var int |
||
| 164 | * |
||
| 165 | * @ORM\Column(name="document_access", type="integer", nullable=false, options={"default":0}) |
||
| 166 | */ |
||
| 167 | protected $documentAccess; |
||
| 168 | |||
| 169 | /** |
||
| 170 | * @var Course |
||
| 171 | * |
||
| 172 | * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course", inversedBy="groups", cascade={"persist"}) |
||
| 173 | * @ORM\JoinColumn(name="c_id", referencedColumnName="id", nullable=false) |
||
| 174 | */ |
||
| 175 | protected $course; |
||
| 176 | |||
| 177 | /** |
||
| 178 | * @var ArrayCollection |
||
| 179 | * |
||
| 180 | * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CGroupRelUser", mappedBy="group") |
||
| 181 | */ |
||
| 182 | protected $members; |
||
| 183 | |||
| 184 | /** |
||
| 185 | * @var ArrayCollection |
||
| 186 | * |
||
| 187 | * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CGroupRelTutor", mappedBy="group") |
||
| 188 | */ |
||
| 189 | protected $tutors; |
||
| 190 | |||
| 191 | /** |
||
| 192 | * Set name. |
||
| 193 | * |
||
| 194 | * @param string $name |
||
| 195 | * |
||
| 196 | * @return CGroupInfo |
||
| 197 | */ |
||
| 198 | public function setName($name) |
||
| 199 | { |
||
| 200 | $this->name = $name; |
||
| 201 | |||
| 202 | return $this; |
||
| 203 | } |
||
| 204 | |||
| 205 | /** |
||
| 206 | * Get name. |
||
| 207 | * |
||
| 208 | * @return string |
||
| 209 | */ |
||
| 210 | public function getName() |
||
| 211 | { |
||
| 212 | return $this->name; |
||
| 213 | } |
||
| 214 | |||
| 215 | /** |
||
| 216 | * Set status. |
||
| 217 | * |
||
| 218 | * @param bool $status |
||
| 219 | * |
||
| 220 | * @return CGroupInfo |
||
| 221 | */ |
||
| 222 | public function setStatus($status) |
||
| 223 | { |
||
| 224 | $this->status = $status; |
||
| 225 | |||
| 226 | return $this; |
||
| 227 | } |
||
| 228 | |||
| 229 | /** |
||
| 230 | * Get status. |
||
| 231 | * |
||
| 232 | * @return bool |
||
| 233 | */ |
||
| 234 | public function getStatus() |
||
| 235 | { |
||
| 236 | return $this->status; |
||
| 237 | } |
||
| 238 | |||
| 239 | /** |
||
| 240 | * Set categoryId. |
||
| 241 | * |
||
| 242 | * @param int $categoryId |
||
| 243 | * |
||
| 244 | * @return CGroupInfo |
||
| 245 | */ |
||
| 246 | public function setCategoryId($categoryId) |
||
| 247 | { |
||
| 248 | $this->categoryId = $categoryId; |
||
| 249 | |||
| 250 | return $this; |
||
| 251 | } |
||
| 252 | |||
| 253 | /** |
||
| 254 | * Get categoryId. |
||
| 255 | * |
||
| 256 | * @return int |
||
| 257 | */ |
||
| 258 | public function getCategoryId() |
||
| 259 | { |
||
| 260 | return $this->categoryId; |
||
| 261 | } |
||
| 262 | |||
| 263 | /** |
||
| 264 | * Set description. |
||
| 265 | * |
||
| 266 | * @param string $description |
||
| 267 | * |
||
| 268 | * @return CGroupInfo |
||
| 269 | */ |
||
| 270 | public function setDescription($description) |
||
| 271 | { |
||
| 272 | $this->description = $description; |
||
| 273 | |||
| 274 | return $this; |
||
| 275 | } |
||
| 276 | |||
| 277 | /** |
||
| 278 | * Get description. |
||
| 279 | * |
||
| 280 | * @return string |
||
| 281 | */ |
||
| 282 | public function getDescription() |
||
| 283 | { |
||
| 284 | return $this->description; |
||
| 285 | } |
||
| 286 | |||
| 287 | /** |
||
| 288 | * Set maxStudent. |
||
| 289 | * |
||
| 290 | * @param int $maxStudent |
||
| 291 | * |
||
| 292 | * @return CGroupInfo |
||
| 293 | */ |
||
| 294 | public function setMaxStudent($maxStudent) |
||
| 295 | { |
||
| 296 | $this->maxStudent = $maxStudent; |
||
| 297 | |||
| 298 | return $this; |
||
| 299 | } |
||
| 300 | |||
| 301 | /** |
||
| 302 | * Get maxStudent. |
||
| 303 | * |
||
| 304 | * @return int |
||
| 305 | */ |
||
| 306 | public function getMaxStudent() |
||
| 307 | { |
||
| 308 | return $this->maxStudent; |
||
| 309 | } |
||
| 310 | |||
| 311 | /** |
||
| 312 | * Set docState. |
||
| 313 | * |
||
| 314 | * @param bool $docState |
||
| 315 | * |
||
| 316 | * @return CGroupInfo |
||
| 317 | */ |
||
| 318 | public function setDocState($docState) |
||
| 319 | { |
||
| 320 | $this->docState = $docState; |
||
| 321 | |||
| 322 | return $this; |
||
| 323 | } |
||
| 324 | |||
| 325 | /** |
||
| 326 | * Get docState. |
||
| 327 | * |
||
| 328 | * @return bool |
||
| 329 | */ |
||
| 330 | public function getDocState() |
||
| 331 | { |
||
| 332 | return $this->docState; |
||
| 333 | } |
||
| 334 | |||
| 335 | /** |
||
| 336 | * Set calendarState. |
||
| 337 | * |
||
| 338 | * @param bool $calendarState |
||
| 339 | * |
||
| 340 | * @return CGroupInfo |
||
| 341 | */ |
||
| 342 | public function setCalendarState($calendarState) |
||
| 343 | { |
||
| 344 | $this->calendarState = $calendarState; |
||
| 345 | |||
| 346 | return $this; |
||
| 347 | } |
||
| 348 | |||
| 349 | /** |
||
| 350 | * Get calendarState. |
||
| 351 | * |
||
| 352 | * @return bool |
||
| 353 | */ |
||
| 354 | public function getCalendarState() |
||
| 355 | { |
||
| 356 | return $this->calendarState; |
||
| 357 | } |
||
| 358 | |||
| 359 | /** |
||
| 360 | * Set workState. |
||
| 361 | * |
||
| 362 | * @param bool $workState |
||
| 363 | * |
||
| 364 | * @return CGroupInfo |
||
| 365 | */ |
||
| 366 | public function setWorkState($workState) |
||
| 367 | { |
||
| 368 | $this->workState = $workState; |
||
| 369 | |||
| 370 | return $this; |
||
| 371 | } |
||
| 372 | |||
| 373 | /** |
||
| 374 | * Get workState. |
||
| 375 | * |
||
| 376 | * @return bool |
||
| 377 | */ |
||
| 378 | public function getWorkState() |
||
| 379 | { |
||
| 380 | return $this->workState; |
||
| 381 | } |
||
| 382 | |||
| 383 | /** |
||
| 384 | * Set announcementsState. |
||
| 385 | * |
||
| 386 | * @param bool $announcementsState |
||
| 387 | * |
||
| 388 | * @return CGroupInfo |
||
| 389 | */ |
||
| 390 | public function setAnnouncementsState($announcementsState) |
||
| 391 | { |
||
| 392 | $this->announcementsState = $announcementsState; |
||
| 393 | |||
| 394 | return $this; |
||
| 395 | } |
||
| 396 | |||
| 397 | /** |
||
| 398 | * Get announcementsState. |
||
| 399 | * |
||
| 400 | * @return bool |
||
| 401 | */ |
||
| 402 | public function getAnnouncementsState() |
||
| 403 | { |
||
| 404 | return $this->announcementsState; |
||
| 405 | } |
||
| 406 | |||
| 407 | /** |
||
| 408 | * Set forumState. |
||
| 409 | * |
||
| 410 | * @param bool $forumState |
||
| 411 | * |
||
| 412 | * @return CGroupInfo |
||
| 413 | */ |
||
| 414 | public function setForumState($forumState) |
||
| 415 | { |
||
| 416 | $this->forumState = $forumState; |
||
| 417 | |||
| 418 | return $this; |
||
| 419 | } |
||
| 420 | |||
| 421 | /** |
||
| 422 | * Get forumState. |
||
| 423 | * |
||
| 424 | * @return bool |
||
| 425 | */ |
||
| 426 | public function getForumState() |
||
| 427 | { |
||
| 428 | return $this->forumState; |
||
| 429 | } |
||
| 430 | |||
| 431 | /** |
||
| 432 | * Set wikiState. |
||
| 433 | * |
||
| 434 | * @param bool $wikiState |
||
| 435 | * |
||
| 436 | * @return CGroupInfo |
||
| 437 | */ |
||
| 438 | public function setWikiState($wikiState) |
||
| 439 | { |
||
| 440 | $this->wikiState = $wikiState; |
||
| 441 | |||
| 442 | return $this; |
||
| 443 | } |
||
| 444 | |||
| 445 | /** |
||
| 446 | * Get wikiState. |
||
| 447 | * |
||
| 448 | * @return bool |
||
| 449 | */ |
||
| 450 | public function getWikiState() |
||
| 451 | { |
||
| 452 | return $this->wikiState; |
||
| 453 | } |
||
| 454 | |||
| 455 | /** |
||
| 456 | * Set chatState. |
||
| 457 | * |
||
| 458 | * @param bool $chatState |
||
| 459 | * |
||
| 460 | * @return CGroupInfo |
||
| 461 | */ |
||
| 462 | public function setChatState($chatState) |
||
| 463 | { |
||
| 464 | $this->chatState = $chatState; |
||
| 465 | |||
| 466 | return $this; |
||
| 467 | } |
||
| 468 | |||
| 469 | /** |
||
| 470 | * Get chatState. |
||
| 471 | * |
||
| 472 | * @return bool |
||
| 473 | */ |
||
| 474 | public function getChatState() |
||
| 475 | { |
||
| 476 | return $this->chatState; |
||
| 477 | } |
||
| 478 | |||
| 479 | /** |
||
| 480 | * Set secretDirectory. |
||
| 481 | * |
||
| 482 | * @param string $secretDirectory |
||
| 483 | * |
||
| 484 | * @return CGroupInfo |
||
| 485 | */ |
||
| 486 | public function setSecretDirectory($secretDirectory) |
||
| 487 | { |
||
| 488 | $this->secretDirectory = $secretDirectory; |
||
| 489 | |||
| 490 | return $this; |
||
| 491 | } |
||
| 492 | |||
| 493 | /** |
||
| 494 | * Get secretDirectory. |
||
| 495 | * |
||
| 496 | * @return string |
||
| 497 | */ |
||
| 498 | public function getSecretDirectory() |
||
| 499 | { |
||
| 500 | return $this->secretDirectory; |
||
| 501 | } |
||
| 502 | |||
| 503 | /** |
||
| 504 | * Set selfRegistrationAllowed. |
||
| 505 | * |
||
| 506 | * @param bool $selfRegistrationAllowed |
||
| 507 | * |
||
| 508 | * @return CGroupInfo |
||
| 509 | */ |
||
| 510 | public function setSelfRegistrationAllowed($selfRegistrationAllowed) |
||
| 511 | { |
||
| 512 | $this->selfRegistrationAllowed = $selfRegistrationAllowed; |
||
| 513 | |||
| 514 | return $this; |
||
| 515 | } |
||
| 516 | |||
| 517 | /** |
||
| 518 | * Get selfRegistrationAllowed. |
||
| 519 | * |
||
| 520 | * @return bool |
||
| 521 | */ |
||
| 522 | public function getSelfRegistrationAllowed() |
||
| 523 | { |
||
| 524 | return $this->selfRegistrationAllowed; |
||
| 525 | } |
||
| 526 | |||
| 527 | /** |
||
| 528 | * Set selfUnregistrationAllowed. |
||
| 529 | * |
||
| 530 | * @param bool $selfUnregistrationAllowed |
||
| 531 | * |
||
| 532 | * @return CGroupInfo |
||
| 533 | */ |
||
| 534 | public function setSelfUnregistrationAllowed($selfUnregistrationAllowed) |
||
| 535 | { |
||
| 536 | $this->selfUnregistrationAllowed = $selfUnregistrationAllowed; |
||
| 537 | |||
| 538 | return $this; |
||
| 539 | } |
||
| 540 | |||
| 541 | /** |
||
| 542 | * Get selfUnregistrationAllowed. |
||
| 543 | * |
||
| 544 | * @return bool |
||
| 545 | */ |
||
| 546 | public function getSelfUnregistrationAllowed() |
||
| 549 | } |
||
| 550 | |||
| 551 | /** |
||
| 552 | * Set sessionId. |
||
| 553 | * |
||
| 554 | * @param int $sessionId |
||
| 555 | * |
||
| 556 | * @return CGroupInfo |
||
| 557 | */ |
||
| 558 | public function setSessionId($sessionId) |
||
| 563 | } |
||
| 564 | |||
| 565 | /** |
||
| 566 | * Get sessionId. |
||
| 567 | * |
||
| 568 | * @return int |
||
| 569 | */ |
||
| 570 | public function getSessionId() |
||
| 571 | { |
||
| 572 | return $this->sessionId; |
||
| 573 | } |
||
| 574 | |||
| 575 | /** |
||
| 576 | * Set id. |
||
| 577 | * |
||
| 578 | * @param int $id |
||
| 579 | * |
||
| 580 | * @return CGroupInfo |
||
| 581 | */ |
||
| 582 | public function setId($id) |
||
| 583 | { |
||
| 584 | $this->id = $id; |
||
| 585 | |||
| 586 | return $this; |
||
| 587 | } |
||
| 588 | |||
| 589 | /** |
||
| 590 | * Get id. |
||
| 591 | * |
||
| 592 | * @return int |
||
| 593 | */ |
||
| 594 | public function getId() |
||
| 595 | { |
||
| 596 | return $this->id; |
||
| 597 | } |
||
| 598 | |||
| 599 | /** |
||
| 600 | * @return int |
||
| 601 | */ |
||
| 602 | public function getDocumentAccess(): int |
||
| 605 | } |
||
| 606 | |||
| 607 | /** |
||
| 608 | * @param int $documentAccess |
||
| 609 | * |
||
| 610 | * @return CGroupInfo |
||
| 611 | */ |
||
| 612 | public function setDocumentAccess(int $documentAccess): CGroupInfo |
||
| 617 | } |
||
| 618 | |||
| 619 | /** |
||
| 620 | * @return int |
||
| 621 | */ |
||
| 622 | public function getDocAccess(): int |
||
| 623 | { |
||
| 624 | return $this->docAccess; |
||
| 625 | } |
||
| 626 | |||
| 627 | /** |
||
| 628 | * @param int $docAccess |
||
| 629 | * |
||
| 630 | * @return CGroupInfo |
||
| 631 | */ |
||
| 632 | public function setDocAccess(int $docAccess): CGroupInfo |
||
| 633 | { |
||
| 634 | $this->docAccess = $docAccess; |
||
| 635 | |||
| 636 | return $this; |
||
| 637 | } |
||
| 638 | |||
| 639 | /** |
||
| 640 | * @return ArrayCollection |
||
| 641 | */ |
||
| 642 | public function getMembers(): ArrayCollection |
||
| 643 | { |
||
| 644 | return $this->members; |
||
| 645 | } |
||
| 646 | |||
| 647 | /** |
||
| 648 | * @param ArrayCollection $members |
||
| 649 | * |
||
| 650 | * @return CGroupInfo |
||
| 651 | */ |
||
| 652 | public function setMembers(ArrayCollection $members): CGroupInfo |
||
| 653 | { |
||
| 654 | $this->members = $members; |
||
| 655 | |||
| 656 | return $this; |
||
| 657 | } |
||
| 658 | |||
| 659 | /** |
||
| 660 | * @return ArrayCollection |
||
| 661 | */ |
||
| 662 | public function getTutors(): ArrayCollection |
||
| 663 | { |
||
| 664 | return $this->tutors; |
||
| 665 | } |
||
| 666 | |||
| 667 | /** |
||
| 668 | * @param ArrayCollection $tutors |
||
| 669 | * |
||
| 670 | * @return CGroupInfo |
||
| 671 | */ |
||
| 672 | public function setTutors(ArrayCollection $tutors): CGroupInfo |
||
| 677 | } |
||
| 678 | } |
||
| 679 |