| Total Complexity | 40 |
| Total Lines | 288 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like CPeerAssessment 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 CPeerAssessment, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 17 | #[ORM\Table(name: 'c_peer_assessment')] |
||
| 18 | #[ORM\Entity] |
||
| 19 | class CPeerAssessment |
||
| 20 | { |
||
| 21 | use TimestampableEntity; |
||
| 22 | use CourseTrait; |
||
| 23 | |||
| 24 | #[ORM\Id] |
||
| 25 | #[ORM\GeneratedValue] |
||
| 26 | #[ORM\Column(type: 'integer')] |
||
| 27 | protected ?int $id = null; |
||
| 28 | |||
| 29 | #[ORM\ManyToOne(targetEntity: Course::class)] |
||
| 30 | #[ORM\JoinColumn(name: 'c_id', referencedColumnName: 'id', nullable: true, onDelete: 'CASCADE')] |
||
| 31 | protected ?Course $course = null; |
||
| 32 | |||
| 33 | #[ORM\ManyToOne(targetEntity: CGroupCategory::class)] |
||
| 34 | #[ORM\JoinColumn(name: 'group_category_id', referencedColumnName: 'iid', nullable: true, onDelete: 'CASCADE')] |
||
| 35 | protected ?CGroupCategory $groupCategory = null; |
||
| 36 | |||
| 37 | #[ORM\Column(type: 'integer', nullable: true, options: ['default' => 0])] |
||
| 38 | protected ?int $maxCorrectionPerStudent = 0; |
||
| 39 | |||
| 40 | #[ORM\Column(type: 'integer', nullable: true, options: ['default' => 0])] |
||
| 41 | protected ?int $state = 0; |
||
| 42 | |||
| 43 | #[ORM\Column(type: 'integer', nullable: true, options: ['default' => 0])] |
||
| 44 | protected ?int $startWorkRepositoryOption = 0; |
||
| 45 | |||
| 46 | #[ORM\Column(type: 'integer', nullable: true)] |
||
| 47 | protected ?int $endWorkRepositoryOption = null; |
||
| 48 | |||
| 49 | #[ORM\Column(type: 'integer', nullable: true, options: ['default' => 0])] |
||
| 50 | protected ?int $startCorrectionOption = 0; |
||
| 51 | |||
| 52 | #[ORM\Column(type: 'integer', nullable: true, options: ['default' => 0])] |
||
| 53 | protected ?int $endCorrectionOption = 0; |
||
| 54 | |||
| 55 | #[ORM\Column(type: 'integer', nullable: false, options: ['default' => 0])] |
||
| 56 | protected int $distributeCorrectionOption = 0; |
||
| 57 | |||
| 58 | #[ORM\Column(type: 'integer', nullable: true)] |
||
| 59 | protected ?int $endRepositoryOption = null; |
||
| 60 | |||
| 61 | #[ORM\Column(type: 'boolean', nullable: true, options: ['default' => 0])] |
||
| 62 | protected ?bool $examinerRoleCondition = false; |
||
| 63 | |||
| 64 | #[ORM\Column(type: 'boolean', nullable: true, options: ['default' => 0])] |
||
| 65 | protected ?bool $studentAccessToCorrection = false; |
||
| 66 | |||
| 67 | #[ORM\Column(type: 'boolean', nullable: true, options: ['default' => 0])] |
||
| 68 | protected ?bool $commentConstraint = false; |
||
| 69 | |||
| 70 | #[ORM\Column(type: 'boolean', nullable: true, options: ['default' => 0])] |
||
| 71 | protected ?bool $correctOwnWork = false; |
||
| 72 | |||
| 73 | #[ORM\Column(type: 'boolean', nullable: true, options: ['default' => 0])] |
||
| 74 | protected ?bool $correctBenchmarkWork = false; |
||
| 75 | |||
| 76 | #[ORM\Column(type: 'boolean', nullable: true, options: ['default' => 0])] |
||
| 77 | protected ?bool $distributionAlgorithm = false; |
||
| 78 | |||
| 79 | #[ORM\Column(type: 'datetime', nullable: true)] |
||
| 80 | protected ?\DateTime $sendWorkStartDate = null; |
||
| 81 | |||
| 82 | #[ORM\Column(type: 'datetime', nullable: true)] |
||
| 83 | protected ?\DateTime $sendWorkEndDate = null; |
||
| 84 | |||
| 85 | #[ORM\Column(type: 'datetime', nullable: true)] |
||
| 86 | protected ?\DateTime $startCorrectionDate = null; |
||
| 87 | |||
| 88 | #[ORM\Column(type: 'datetime', nullable: true)] |
||
| 89 | protected ?\DateTime $endCorrectionDate = null; |
||
| 90 | |||
| 91 | public function __construct() {} |
||
| 92 | |||
| 93 | public function getId(): ?int |
||
| 94 | { |
||
| 95 | return $this->id; |
||
| 96 | } |
||
| 97 | |||
| 98 | public function getGroupCategory(): ?CGroupCategory |
||
| 99 | { |
||
| 100 | return $this->groupCategory; |
||
| 101 | } |
||
| 102 | |||
| 103 | public function setGroupCategory(?CGroupCategory $groupCategory): self |
||
| 104 | { |
||
| 105 | $this->groupCategory = $groupCategory; |
||
| 106 | return $this; |
||
| 107 | } |
||
| 108 | |||
| 109 | public function getMaxCorrectionPerStudent(): ?int |
||
| 110 | { |
||
| 111 | return $this->maxCorrectionPerStudent; |
||
| 112 | } |
||
| 113 | |||
| 114 | public function setMaxCorrectionPerStudent(?int $maxCorrectionPerStudent): self |
||
| 115 | { |
||
| 116 | $this->maxCorrectionPerStudent = $maxCorrectionPerStudent; |
||
| 117 | return $this; |
||
| 118 | } |
||
| 119 | |||
| 120 | public function getState(): ?int |
||
| 121 | { |
||
| 122 | return $this->state; |
||
| 123 | } |
||
| 124 | |||
| 125 | public function setState(?int $state): self |
||
| 126 | { |
||
| 127 | $this->state = $state; |
||
| 128 | return $this; |
||
| 129 | } |
||
| 130 | |||
| 131 | public function getStartWorkRepositoryOption(): ?int |
||
| 132 | { |
||
| 133 | return $this->startWorkRepositoryOption; |
||
| 134 | } |
||
| 135 | |||
| 136 | public function setStartWorkRepositoryOption(?int $startWorkRepositoryOption): self |
||
| 137 | { |
||
| 138 | $this->startWorkRepositoryOption = $startWorkRepositoryOption; |
||
| 139 | return $this; |
||
| 140 | } |
||
| 141 | |||
| 142 | public function getEndWorkRepositoryOption(): ?int |
||
| 143 | { |
||
| 144 | return $this->endWorkRepositoryOption; |
||
| 145 | } |
||
| 146 | |||
| 147 | public function setEndWorkRepositoryOption(?int $endWorkRepositoryOption): self |
||
| 148 | { |
||
| 149 | $this->endWorkRepositoryOption = $endWorkRepositoryOption; |
||
| 150 | return $this; |
||
| 151 | } |
||
| 152 | |||
| 153 | public function getStartCorrectionOption(): ?int |
||
| 154 | { |
||
| 155 | return $this->startCorrectionOption; |
||
| 156 | } |
||
| 157 | |||
| 158 | public function setStartCorrectionOption(?int $startCorrectionOption): self |
||
| 159 | { |
||
| 160 | $this->startCorrectionOption = $startCorrectionOption; |
||
| 161 | return $this; |
||
| 162 | } |
||
| 163 | |||
| 164 | public function getEndCorrectionOption(): ?int |
||
| 167 | } |
||
| 168 | |||
| 169 | public function setEndCorrectionOption(?int $endCorrectionOption): self |
||
| 170 | { |
||
| 171 | $this->endCorrectionOption = $endCorrectionOption; |
||
| 172 | return $this; |
||
| 173 | } |
||
| 174 | |||
| 175 | public function getDistributeCorrectionOption(): int |
||
| 176 | { |
||
| 177 | return $this->distributeCorrectionOption; |
||
| 178 | } |
||
| 179 | |||
| 180 | public function setDistributeCorrectionOption(int $distributeCorrectionOption): self |
||
| 181 | { |
||
| 182 | $this->distributeCorrectionOption = $distributeCorrectionOption; |
||
| 183 | return $this; |
||
| 184 | } |
||
| 185 | |||
| 186 | public function getEndRepositoryOption(): ?int |
||
| 187 | { |
||
| 188 | return $this->endRepositoryOption; |
||
| 189 | } |
||
| 190 | |||
| 191 | public function setEndRepositoryOption(?int $endRepositoryOption): self |
||
| 192 | { |
||
| 193 | $this->endRepositoryOption = $endRepositoryOption; |
||
| 194 | return $this; |
||
| 195 | } |
||
| 196 | |||
| 197 | public function getExaminerRoleCondition(): ?bool |
||
| 198 | { |
||
| 199 | return $this->examinerRoleCondition; |
||
| 200 | } |
||
| 201 | |||
| 202 | public function setExaminerRoleCondition(?bool $examinerRoleCondition): self |
||
| 203 | { |
||
| 204 | $this->examinerRoleCondition = $examinerRoleCondition; |
||
| 205 | return $this; |
||
| 206 | } |
||
| 207 | |||
| 208 | public function getStudentAccessToCorrection(): ?bool |
||
| 209 | { |
||
| 210 | return $this->studentAccessToCorrection; |
||
| 211 | } |
||
| 212 | |||
| 213 | public function setStudentAccessToCorrection(?bool $studentAccessToCorrection): self |
||
| 214 | { |
||
| 215 | $this->studentAccessToCorrection = $studentAccessToCorrection; |
||
| 216 | return $this; |
||
| 217 | } |
||
| 218 | |||
| 219 | public function getCommentConstraint(): ?bool |
||
| 220 | { |
||
| 221 | return $this->commentConstraint; |
||
| 222 | } |
||
| 223 | |||
| 224 | public function setCommentConstraint(?bool $commentConstraint): self |
||
| 225 | { |
||
| 226 | $this->commentConstraint = $commentConstraint; |
||
| 227 | return $this; |
||
| 228 | } |
||
| 229 | |||
| 230 | public function getCorrectOwnWork(): ?bool |
||
| 231 | { |
||
| 232 | return $this->correctOwnWork; |
||
| 233 | } |
||
| 234 | |||
| 235 | public function setCorrectOwnWork(?bool $correctOwnWork): self |
||
| 236 | { |
||
| 237 | $this->correctOwnWork = $correctOwnWork; |
||
| 238 | return $this; |
||
| 239 | } |
||
| 240 | |||
| 241 | public function getCorrectBenchmarkWork(): ?bool |
||
| 242 | { |
||
| 243 | return $this->correctBenchmarkWork; |
||
| 244 | } |
||
| 245 | |||
| 246 | public function setCorrectBenchmarkWork(?bool $correctBenchmarkWork): self |
||
| 247 | { |
||
| 248 | $this->correctBenchmarkWork = $correctBenchmarkWork; |
||
| 249 | return $this; |
||
| 250 | } |
||
| 251 | |||
| 252 | public function getDistributionAlgorithm(): ?bool |
||
| 253 | { |
||
| 254 | return $this->distributionAlgorithm; |
||
| 255 | } |
||
| 256 | |||
| 257 | public function setDistributionAlgorithm(?bool $distributionAlgorithm): self |
||
| 258 | { |
||
| 259 | $this->distributionAlgorithm = $distributionAlgorithm; |
||
| 260 | return $this; |
||
| 261 | } |
||
| 262 | |||
| 263 | public function getSendWorkStartDate(): ?\DateTime |
||
| 264 | { |
||
| 265 | return $this->sendWorkStartDate; |
||
| 266 | } |
||
| 267 | |||
| 268 | public function setSendWorkStartDate(?\DateTime $sendWorkStartDate): self |
||
| 269 | { |
||
| 270 | $this->sendWorkStartDate = $sendWorkStartDate; |
||
| 271 | return $this; |
||
| 272 | } |
||
| 273 | |||
| 274 | public function getSendWorkEndDate(): ?\DateTime |
||
| 275 | { |
||
| 276 | return $this->sendWorkEndDate; |
||
| 277 | } |
||
| 278 | |||
| 279 | public function setSendWorkEndDate(?\DateTime $sendWorkEndDate): self |
||
| 283 | } |
||
| 284 | |||
| 285 | public function getStartCorrectionDate(): ?\DateTime |
||
| 286 | { |
||
| 287 | return $this->startCorrectionDate; |
||
| 288 | } |
||
| 289 | |||
| 290 | public function setStartCorrectionDate(?\DateTime $startCorrectionDate): self |
||
| 294 | } |
||
| 295 | |||
| 296 | public function getEndCorrectionDate(): ?\DateTime |
||
| 297 | { |
||
| 298 | return $this->endCorrectionDate; |
||
| 299 | } |
||
| 300 | |||
| 301 | public function setEndCorrectionDate(?\DateTime $endCorrectionDate): self |
||
| 305 | } |
||
| 306 | } |
||
| 307 |