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