Total Complexity | 55 |
Total Lines | 838 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Complex classes like CQuiz 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 CQuiz, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
20 | class CQuiz |
||
21 | { |
||
22 | /** |
||
23 | * @var int |
||
24 | * |
||
25 | * @ORM\Column(name="iid", type="integer") |
||
26 | * @ORM\Id |
||
27 | * @ORM\GeneratedValue |
||
28 | */ |
||
29 | protected $iid; |
||
30 | |||
31 | /** |
||
32 | * @var int |
||
33 | * |
||
34 | * @deprecated Now using iid |
||
35 | * @ORM\Column(name="c_id", type="integer") |
||
36 | */ |
||
37 | protected $cId; |
||
38 | |||
39 | /** |
||
40 | * @var int |
||
41 | * |
||
42 | * @deprecated Now using iid |
||
43 | * @ORM\Column(name="id", type="integer", nullable=true) |
||
44 | */ |
||
45 | protected $id; |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | * |
||
50 | * @ORM\Column(name="title", type="string", length=255, nullable=false) |
||
51 | */ |
||
52 | protected $title; |
||
53 | |||
54 | /** |
||
55 | * @var string |
||
56 | * |
||
57 | * @ORM\Column(name="description", type="text", nullable=true) |
||
58 | */ |
||
59 | protected $description; |
||
60 | |||
61 | /** |
||
62 | * @var string |
||
63 | * |
||
64 | * @ORM\Column(name="sound", type="string", length=255, nullable=true) |
||
65 | */ |
||
66 | protected $sound; |
||
67 | |||
68 | /** |
||
69 | * @var bool |
||
70 | * |
||
71 | * @ORM\Column(name="type", type="boolean", nullable=false) |
||
72 | */ |
||
73 | protected $type; |
||
74 | |||
75 | /** |
||
76 | * @var int |
||
77 | * |
||
78 | * @ORM\Column(name="random", type="integer", nullable=false) |
||
79 | */ |
||
80 | protected $random; |
||
81 | |||
82 | /** |
||
83 | * @var bool |
||
84 | * |
||
85 | * @ORM\Column(name="random_answers", type="boolean", nullable=false) |
||
86 | */ |
||
87 | protected $randomAnswers; |
||
88 | |||
89 | /** |
||
90 | * @var bool |
||
91 | * |
||
92 | * @ORM\Column(name="active", type="boolean", nullable=false) |
||
93 | */ |
||
94 | protected $active; |
||
95 | |||
96 | /** |
||
97 | * @var int |
||
98 | * |
||
99 | * @ORM\Column(name="results_disabled", type="integer", nullable=false) |
||
100 | */ |
||
101 | protected $resultsDisabled; |
||
102 | |||
103 | /** |
||
104 | * @var string |
||
105 | * |
||
106 | * @ORM\Column(name="access_condition", type="text", nullable=true) |
||
107 | */ |
||
108 | protected $accessCondition; |
||
109 | |||
110 | /** |
||
111 | * @var int |
||
112 | * |
||
113 | * @ORM\Column(name="max_attempt", type="integer", nullable=false) |
||
114 | */ |
||
115 | protected $maxAttempt; |
||
116 | |||
117 | /** |
||
118 | * @var \DateTime |
||
119 | * |
||
120 | * @ORM\Column(name="start_time", type="datetime", nullable=true) |
||
121 | */ |
||
122 | protected $startTime; |
||
123 | |||
124 | /** |
||
125 | * @var \DateTime |
||
126 | * |
||
127 | * @ORM\Column(name="end_time", type="datetime", nullable=true) |
||
128 | */ |
||
129 | protected $endTime; |
||
130 | |||
131 | /** |
||
132 | * @var int |
||
133 | * |
||
134 | * @ORM\Column(name="feedback_type", type="integer", nullable=false) |
||
135 | */ |
||
136 | protected $feedbackType; |
||
137 | |||
138 | /** |
||
139 | * @var int |
||
140 | * |
||
141 | * @ORM\Column(name="expired_time", type="integer", nullable=false) |
||
142 | */ |
||
143 | protected $expiredTime; |
||
144 | |||
145 | /** |
||
146 | * @var int |
||
147 | * |
||
148 | * @ORM\Column(name="session_id", type="integer", nullable=true) |
||
149 | */ |
||
150 | protected $sessionId; |
||
151 | |||
152 | /** |
||
153 | * @var int |
||
154 | * |
||
155 | * @ORM\Column(name="propagate_neg", type="integer", nullable=false) |
||
156 | */ |
||
157 | protected $propagateNeg; |
||
158 | |||
159 | /** |
||
160 | * @var bool |
||
161 | * @ORm\Column(name="save_correct_answers", type="boolean", nullable=false) |
||
162 | */ |
||
163 | protected $saveCorrectAnswers; |
||
164 | |||
165 | /** |
||
166 | * @var int |
||
167 | * |
||
168 | * @ORM\Column(name="review_answers", type="integer", nullable=false) |
||
169 | */ |
||
170 | protected $reviewAnswers; |
||
171 | |||
172 | /** |
||
173 | * @var int |
||
174 | * |
||
175 | * @ORM\Column(name="random_by_category", type="integer", nullable=false) |
||
176 | */ |
||
177 | protected $randomByCategory; |
||
178 | |||
179 | /** |
||
180 | * @var string |
||
181 | * |
||
182 | * @ORM\Column(name="text_when_finished", type="text", nullable=true) |
||
183 | */ |
||
184 | protected $textWhenFinished; |
||
185 | |||
186 | /** |
||
187 | * @var string|null |
||
188 | * |
||
189 | * ORM\Column(name="text_when_finished_failure", type="text", nullable=true) |
||
190 | */ |
||
191 | protected ?string $textWhenFinishedFailure = null; |
||
192 | |||
193 | /** |
||
194 | * @var int |
||
195 | * |
||
196 | * @ORM\Column(name="display_category_name", type="integer", nullable=false) |
||
197 | */ |
||
198 | protected $displayCategoryName; |
||
199 | |||
200 | /** |
||
201 | * @var int |
||
202 | * |
||
203 | * @ORM\Column(name="pass_percentage", type="integer", nullable=true) |
||
204 | */ |
||
205 | protected $passPercentage; |
||
206 | |||
207 | /** |
||
208 | * @var int |
||
209 | * |
||
210 | * @ORM\Column(name="question_selection_type", type="integer", nullable=true) |
||
211 | */ |
||
212 | protected $questionSelectionType; |
||
213 | |||
214 | /** |
||
215 | * @var bool |
||
216 | * |
||
217 | * @ORM\Column(name="hide_question_title", type="boolean", nullable=true) |
||
218 | */ |
||
219 | protected $hideQuestionTitle; |
||
220 | |||
221 | /** |
||
222 | * @var int |
||
223 | * |
||
224 | * ORM\Column(name="exercise_category_id", type="integer", nullable=true) |
||
225 | */ |
||
226 | protected $exerciseCategoryId; |
||
227 | |||
228 | /** |
||
229 | * CQuiz constructor. |
||
230 | */ |
||
231 | public function __construct() |
||
232 | { |
||
233 | $this->hideQuestionTitle = false; |
||
234 | } |
||
235 | |||
236 | /** |
||
237 | * Set title. |
||
238 | * |
||
239 | * @param string $title |
||
240 | * |
||
241 | * @return CQuiz |
||
242 | */ |
||
243 | public function setTitle($title) |
||
244 | { |
||
245 | $this->title = $title; |
||
246 | |||
247 | return $this; |
||
248 | } |
||
249 | |||
250 | /** |
||
251 | * Get title. |
||
252 | * |
||
253 | * @return string |
||
254 | */ |
||
255 | public function getTitle() |
||
256 | { |
||
257 | return $this->title; |
||
258 | } |
||
259 | |||
260 | /** |
||
261 | * Set description. |
||
262 | * |
||
263 | * @param string $description |
||
264 | * |
||
265 | * @return CQuiz |
||
266 | */ |
||
267 | public function setDescription($description) |
||
268 | { |
||
269 | $this->description = $description; |
||
270 | |||
271 | return $this; |
||
272 | } |
||
273 | |||
274 | /** |
||
275 | * Get description. |
||
276 | * |
||
277 | * @return string |
||
278 | */ |
||
279 | public function getDescription() |
||
280 | { |
||
281 | return $this->description; |
||
282 | } |
||
283 | |||
284 | /** |
||
285 | * Set sound. |
||
286 | * |
||
287 | * @param string $sound |
||
288 | * |
||
289 | * @return CQuiz |
||
290 | */ |
||
291 | public function setSound($sound) |
||
292 | { |
||
293 | $this->sound = $sound; |
||
294 | |||
295 | return $this; |
||
296 | } |
||
297 | |||
298 | /** |
||
299 | * Get sound. |
||
300 | * |
||
301 | * @return string |
||
302 | */ |
||
303 | public function getSound() |
||
304 | { |
||
305 | return $this->sound; |
||
306 | } |
||
307 | |||
308 | /** |
||
309 | * Set type. |
||
310 | * |
||
311 | * @param bool $type |
||
312 | * |
||
313 | * @return CQuiz |
||
314 | */ |
||
315 | public function setType($type) |
||
316 | { |
||
317 | $this->type = $type; |
||
318 | |||
319 | return $this; |
||
320 | } |
||
321 | |||
322 | /** |
||
323 | * Get type. |
||
324 | * |
||
325 | * @return bool |
||
326 | */ |
||
327 | public function getType() |
||
328 | { |
||
329 | return $this->type; |
||
330 | } |
||
331 | |||
332 | /** |
||
333 | * Set random. |
||
334 | * |
||
335 | * @param int $random |
||
336 | * |
||
337 | * @return CQuiz |
||
338 | */ |
||
339 | public function setRandom($random) |
||
340 | { |
||
341 | $this->random = $random; |
||
342 | |||
343 | return $this; |
||
344 | } |
||
345 | |||
346 | /** |
||
347 | * Get random. |
||
348 | * |
||
349 | * @return int |
||
350 | */ |
||
351 | public function getRandom() |
||
352 | { |
||
353 | return $this->random; |
||
354 | } |
||
355 | |||
356 | /** |
||
357 | * Set randomAnswers. |
||
358 | * |
||
359 | * @param bool $randomAnswers |
||
360 | * |
||
361 | * @return CQuiz |
||
362 | */ |
||
363 | public function setRandomAnswers($randomAnswers) |
||
364 | { |
||
365 | $this->randomAnswers = $randomAnswers; |
||
366 | |||
367 | return $this; |
||
368 | } |
||
369 | |||
370 | /** |
||
371 | * Get randomAnswers. |
||
372 | * |
||
373 | * @return bool |
||
374 | */ |
||
375 | public function getRandomAnswers() |
||
376 | { |
||
377 | return $this->randomAnswers; |
||
378 | } |
||
379 | |||
380 | /** |
||
381 | * Set active. |
||
382 | * |
||
383 | * @param bool $active |
||
384 | * |
||
385 | * @return CQuiz |
||
386 | */ |
||
387 | public function setActive($active) |
||
388 | { |
||
389 | $this->active = $active; |
||
390 | |||
391 | return $this; |
||
392 | } |
||
393 | |||
394 | /** |
||
395 | * Get active. |
||
396 | * |
||
397 | * @return bool |
||
398 | */ |
||
399 | public function getActive() |
||
400 | { |
||
401 | return $this->active; |
||
402 | } |
||
403 | |||
404 | /** |
||
405 | * Set resultsDisabled. |
||
406 | * |
||
407 | * @param int $resultsDisabled |
||
408 | * |
||
409 | * @return CQuiz |
||
410 | */ |
||
411 | public function setResultsDisabled($resultsDisabled) |
||
412 | { |
||
413 | $this->resultsDisabled = $resultsDisabled; |
||
414 | |||
415 | return $this; |
||
416 | } |
||
417 | |||
418 | /** |
||
419 | * Get resultsDisabled. |
||
420 | * |
||
421 | * @return int |
||
422 | */ |
||
423 | public function getResultsDisabled() |
||
424 | { |
||
425 | return $this->resultsDisabled; |
||
426 | } |
||
427 | |||
428 | /** |
||
429 | * Set accessCondition. |
||
430 | * |
||
431 | * @param string $accessCondition |
||
432 | * |
||
433 | * @return CQuiz |
||
434 | */ |
||
435 | public function setAccessCondition($accessCondition) |
||
436 | { |
||
437 | $this->accessCondition = $accessCondition; |
||
438 | |||
439 | return $this; |
||
440 | } |
||
441 | |||
442 | /** |
||
443 | * Get accessCondition. |
||
444 | * |
||
445 | * @return string |
||
446 | */ |
||
447 | public function getAccessCondition() |
||
448 | { |
||
449 | return $this->accessCondition; |
||
450 | } |
||
451 | |||
452 | /** |
||
453 | * Set maxAttempt. |
||
454 | * |
||
455 | * @param int $maxAttempt |
||
456 | * |
||
457 | * @return CQuiz |
||
458 | */ |
||
459 | public function setMaxAttempt($maxAttempt) |
||
460 | { |
||
461 | $this->maxAttempt = $maxAttempt; |
||
462 | |||
463 | return $this; |
||
464 | } |
||
465 | |||
466 | /** |
||
467 | * Get maxAttempt. |
||
468 | * |
||
469 | * @return int |
||
470 | */ |
||
471 | public function getMaxAttempt() |
||
474 | } |
||
475 | |||
476 | /** |
||
477 | * Set startTime. |
||
478 | * |
||
479 | * @param \DateTime $startTime |
||
480 | * |
||
481 | * @return CQuiz |
||
482 | */ |
||
483 | public function setStartTime($startTime) |
||
484 | { |
||
485 | $this->startTime = $startTime; |
||
486 | |||
487 | return $this; |
||
488 | } |
||
489 | |||
490 | /** |
||
491 | * Get startTime. |
||
492 | * |
||
493 | * @return \DateTime |
||
494 | */ |
||
495 | public function getStartTime() |
||
496 | { |
||
497 | return $this->startTime; |
||
498 | } |
||
499 | |||
500 | /** |
||
501 | * Set endTime. |
||
502 | * |
||
503 | * @param \DateTime $endTime |
||
504 | * |
||
505 | * @return CQuiz |
||
506 | */ |
||
507 | public function setEndTime($endTime) |
||
508 | { |
||
509 | $this->endTime = $endTime; |
||
510 | |||
511 | return $this; |
||
512 | } |
||
513 | |||
514 | /** |
||
515 | * Get endTime. |
||
516 | * |
||
517 | * @return \DateTime |
||
518 | */ |
||
519 | public function getEndTime() |
||
520 | { |
||
521 | return $this->endTime; |
||
522 | } |
||
523 | |||
524 | /** |
||
525 | * Set feedbackType. |
||
526 | * |
||
527 | * @param int $feedbackType |
||
528 | * |
||
529 | * @return CQuiz |
||
530 | */ |
||
531 | public function setFeedbackType($feedbackType) |
||
532 | { |
||
533 | $this->feedbackType = $feedbackType; |
||
534 | |||
535 | return $this; |
||
536 | } |
||
537 | |||
538 | /** |
||
539 | * Get feedbackType. |
||
540 | * |
||
541 | * @return int |
||
542 | */ |
||
543 | public function getFeedbackType() |
||
546 | } |
||
547 | |||
548 | /** |
||
549 | * Set expiredTime. |
||
550 | * |
||
551 | * @param int $expiredTime |
||
552 | * |
||
553 | * @return CQuiz |
||
554 | */ |
||
555 | public function setExpiredTime($expiredTime) |
||
556 | { |
||
557 | $this->expiredTime = $expiredTime; |
||
558 | |||
559 | return $this; |
||
560 | } |
||
561 | |||
562 | /** |
||
563 | * Get expiredTime. |
||
564 | * |
||
565 | * @return int |
||
566 | */ |
||
567 | public function getExpiredTime() |
||
570 | } |
||
571 | |||
572 | /** |
||
573 | * Set sessionId. |
||
574 | * |
||
575 | * @param int $sessionId |
||
576 | * |
||
577 | * @return CQuiz |
||
578 | */ |
||
579 | public function setSessionId($sessionId) |
||
580 | { |
||
581 | $this->sessionId = $sessionId; |
||
582 | |||
583 | return $this; |
||
584 | } |
||
585 | |||
586 | /** |
||
587 | * Get sessionId. |
||
588 | * |
||
589 | * @return int |
||
590 | */ |
||
591 | public function getSessionId() |
||
592 | { |
||
593 | return $this->sessionId; |
||
594 | } |
||
595 | |||
596 | /** |
||
597 | * Set propagateNeg. |
||
598 | * |
||
599 | * @param int $propagateNeg |
||
600 | * |
||
601 | * @return CQuiz |
||
602 | */ |
||
603 | public function setPropagateNeg($propagateNeg) |
||
604 | { |
||
605 | $this->propagateNeg = $propagateNeg; |
||
606 | |||
607 | return $this; |
||
608 | } |
||
609 | |||
610 | /** |
||
611 | * Get propagateNeg. |
||
612 | * |
||
613 | * @return int |
||
614 | */ |
||
615 | public function getPropagateNeg() |
||
616 | { |
||
617 | return $this->propagateNeg; |
||
618 | } |
||
619 | |||
620 | /** |
||
621 | * @param $saveCorrectAnswers boolean |
||
622 | * |
||
623 | * @return CQuiz |
||
624 | */ |
||
625 | public function setSaveCorrectAnswers($saveCorrectAnswers) |
||
626 | { |
||
627 | $this->saveCorrectAnswers = $saveCorrectAnswers; |
||
628 | |||
629 | return $this; |
||
630 | } |
||
631 | |||
632 | /** |
||
633 | * @return bool |
||
634 | */ |
||
635 | public function getSaveCorrectAnswers() |
||
636 | { |
||
637 | return $this->saveCorrectAnswers; |
||
638 | } |
||
639 | |||
640 | /** |
||
641 | * Set reviewAnswers. |
||
642 | * |
||
643 | * @param int $reviewAnswers |
||
644 | * |
||
645 | * @return CQuiz |
||
646 | */ |
||
647 | public function setReviewAnswers($reviewAnswers) |
||
648 | { |
||
649 | $this->reviewAnswers = $reviewAnswers; |
||
650 | |||
651 | return $this; |
||
652 | } |
||
653 | |||
654 | /** |
||
655 | * Get reviewAnswers. |
||
656 | * |
||
657 | * @return int |
||
658 | */ |
||
659 | public function getReviewAnswers() |
||
660 | { |
||
661 | return $this->reviewAnswers; |
||
662 | } |
||
663 | |||
664 | /** |
||
665 | * Set randomByCategory. |
||
666 | * |
||
667 | * @param int $randomByCategory |
||
668 | * |
||
669 | * @return CQuiz |
||
670 | */ |
||
671 | public function setRandomByCategory($randomByCategory) |
||
672 | { |
||
673 | $this->randomByCategory = $randomByCategory; |
||
674 | |||
675 | return $this; |
||
676 | } |
||
677 | |||
678 | /** |
||
679 | * Get randomByCategory. |
||
680 | * |
||
681 | * @return int |
||
682 | */ |
||
683 | public function getRandomByCategory() |
||
684 | { |
||
685 | return $this->randomByCategory; |
||
686 | } |
||
687 | |||
688 | /** |
||
689 | * Set textWhenFinished. |
||
690 | * |
||
691 | * @param string $textWhenFinished |
||
692 | * |
||
693 | * @return CQuiz |
||
694 | */ |
||
695 | public function setTextWhenFinished($textWhenFinished) |
||
696 | { |
||
697 | $this->textWhenFinished = $textWhenFinished; |
||
698 | |||
699 | return $this; |
||
700 | } |
||
701 | |||
702 | /** |
||
703 | * Get textWhenFinished. |
||
704 | * |
||
705 | * @return string |
||
706 | */ |
||
707 | public function getTextWhenFinished() |
||
708 | { |
||
709 | return $this->textWhenFinished; |
||
710 | } |
||
711 | |||
712 | /** |
||
713 | * Set displayCategoryName. |
||
714 | * |
||
715 | * @param int $displayCategoryName |
||
716 | * |
||
717 | * @return CQuiz |
||
718 | */ |
||
719 | public function setDisplayCategoryName($displayCategoryName) |
||
720 | { |
||
721 | $this->displayCategoryName = $displayCategoryName; |
||
722 | |||
723 | return $this; |
||
724 | } |
||
725 | |||
726 | /** |
||
727 | * Get displayCategoryName. |
||
728 | * |
||
729 | * @return int |
||
730 | */ |
||
731 | public function getDisplayCategoryName() |
||
732 | { |
||
733 | return $this->displayCategoryName; |
||
734 | } |
||
735 | |||
736 | /** |
||
737 | * Set passPercentage. |
||
738 | * |
||
739 | * @param int $passPercentage |
||
740 | * |
||
741 | * @return CQuiz |
||
742 | */ |
||
743 | public function setPassPercentage($passPercentage) |
||
744 | { |
||
745 | $this->passPercentage = $passPercentage; |
||
746 | |||
747 | return $this; |
||
748 | } |
||
749 | |||
750 | /** |
||
751 | * Get passPercentage. |
||
752 | * |
||
753 | * @return int |
||
754 | */ |
||
755 | public function getPassPercentage() |
||
756 | { |
||
757 | return $this->passPercentage; |
||
758 | } |
||
759 | |||
760 | /** |
||
761 | * Set id. |
||
762 | * |
||
763 | * @param int $iid |
||
764 | * |
||
765 | * @return CQuiz |
||
766 | */ |
||
767 | public function setId($iid) |
||
768 | { |
||
769 | $this->iid = $iid; |
||
770 | |||
771 | return $this; |
||
772 | } |
||
773 | |||
774 | /** |
||
775 | * Get id. |
||
776 | * |
||
777 | * @return int |
||
778 | */ |
||
779 | public function getId() |
||
780 | { |
||
781 | return $this->iid; |
||
782 | } |
||
783 | |||
784 | /** |
||
785 | * Set cId. |
||
786 | * |
||
787 | * @param int $cId |
||
788 | * |
||
789 | * @return CQuiz |
||
790 | */ |
||
791 | public function setCId($cId) |
||
796 | } |
||
797 | |||
798 | /** |
||
799 | * Get cId. |
||
800 | * |
||
801 | * @return int |
||
802 | */ |
||
803 | public function getCId() |
||
804 | { |
||
805 | return $this->cId; |
||
806 | } |
||
807 | |||
808 | /** |
||
809 | * @return int |
||
810 | */ |
||
811 | public function getQuestionSelectionType() |
||
814 | } |
||
815 | |||
816 | /** |
||
817 | * @param int $questionSelectionType |
||
818 | * |
||
819 | * @return CQuiz |
||
820 | */ |
||
821 | public function setQuestionSelectionType($questionSelectionType) |
||
822 | { |
||
823 | $this->questionSelectionType = $questionSelectionType; |
||
824 | |||
825 | return $this; |
||
826 | } |
||
827 | |||
828 | /** |
||
829 | * @return bool |
||
830 | */ |
||
831 | public function isHideQuestionTitle() |
||
834 | } |
||
835 | |||
836 | /** |
||
837 | * @param bool $hideQuestionTitle |
||
838 | * |
||
839 | * @return CQuiz |
||
840 | */ |
||
841 | public function setHideQuestionTitle($hideQuestionTitle) |
||
842 | { |
||
843 | $this->hideQuestionTitle = $hideQuestionTitle; |
||
844 | |||
845 | return $this; |
||
846 | } |
||
847 | |||
848 | public function getTextWhenFinishedFailure(): ?string |
||
849 | { |
||
850 | return $this->textWhenFinishedFailure; |
||
851 | } |
||
852 | |||
853 | public function setTextWhenFinishedFailure(?string $textWhenFinishedFailure): CQuiz |
||
858 | } |
||
859 | } |
||
860 |
This property 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 property will be removed from the class and what other property to use instead.