| Total Complexity | 80 |
| Total Lines | 636 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like Meeting 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 Meeting, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 44 | class Meeting |
||
| 45 | { |
||
| 46 | /** @var string meeting type name */ |
||
| 47 | public $typeName; |
||
| 48 | |||
| 49 | /** @var DateTime meeting start time as a DateTime instance */ |
||
| 50 | public $startDateTime; |
||
| 51 | |||
| 52 | /** @var string meeting formatted start time */ |
||
| 53 | public $formattedStartTime; |
||
| 54 | |||
| 55 | /** @var DateInterval meeting duration as a DateInterval instance */ |
||
| 56 | public $durationInterval; |
||
| 57 | |||
| 58 | /** @var string meeting formatted duration */ |
||
| 59 | public $formattedDuration; |
||
| 60 | |||
| 61 | /** @var string */ |
||
| 62 | public $statusName; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @var int |
||
| 66 | * @ORM\Column(type="integer", name="id") |
||
| 67 | * @ORM\Id |
||
| 68 | * @ORM\GeneratedValue() |
||
| 69 | */ |
||
| 70 | protected $id; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @var int the remote zoom meeting identifier |
||
| 74 | * @ORM\Column(name="meeting_id", type="string") |
||
| 75 | */ |
||
| 76 | protected $meetingId; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @var User |
||
| 80 | * @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User") |
||
| 81 | * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true) |
||
| 82 | */ |
||
| 83 | protected $user; |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @var Course |
||
| 87 | * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course") |
||
| 88 | * @ORM\JoinColumn(name="course_id", referencedColumnName="id", nullable=true) |
||
| 89 | */ |
||
| 90 | protected $course; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @var CGroupInfo |
||
| 94 | * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CGroupInfo") |
||
| 95 | * @ORM\JoinColumn(name="group_id", referencedColumnName="iid", nullable=true) |
||
| 96 | */ |
||
| 97 | protected $group; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * @var Session |
||
| 101 | * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session") |
||
| 102 | * @ORM\JoinColumn(name="session_id", referencedColumnName="id", nullable=true) |
||
| 103 | */ |
||
| 104 | protected $session; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @var string |
||
| 108 | * @ORM\Column(type="text", name="meeting_list_item_json", nullable=true) |
||
| 109 | */ |
||
| 110 | protected $meetingListItemJson; |
||
| 111 | |||
| 112 | /** |
||
| 113 | * @var string |
||
| 114 | * @ORM\Column(type="text", name="meeting_info_get_json", nullable=true) |
||
| 115 | */ |
||
| 116 | protected $meetingInfoGetJson; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @var bool |
||
| 120 | * |
||
| 121 | * @ORM\Column(type="boolean", name="sign_attendance") |
||
| 122 | */ |
||
| 123 | protected $signAttendance; |
||
| 124 | |||
| 125 | /** |
||
| 126 | * @var string|null |
||
| 127 | * |
||
| 128 | * @ORM\Column(type="text", name="reason_to_sign_attendance", nullable=true) |
||
| 129 | */ |
||
| 130 | protected $reasonToSignAttendance; |
||
| 131 | |||
| 132 | /** @var MeetingListItem */ |
||
| 133 | protected $meetingListItem; |
||
| 134 | |||
| 135 | /** @var MeetingInfoGet */ |
||
| 136 | protected $meetingInfoGet; |
||
| 137 | |||
| 138 | /** |
||
| 139 | * @var MeetingActivity[]|ArrayCollection |
||
| 140 | * @ORM\OrderBy({"createdAt" = "DESC"}) |
||
| 141 | * @ORM\OneToMany(targetEntity="MeetingActivity", mappedBy="meeting", cascade={"persist", "remove"}) |
||
| 142 | */ |
||
| 143 | protected $activities; |
||
| 144 | |||
| 145 | /** |
||
| 146 | * @var Registrant[]|ArrayCollection |
||
| 147 | * |
||
| 148 | * @ORM\OneToMany(targetEntity="Registrant", mappedBy="meeting", cascade={"persist", "remove"}) |
||
| 149 | */ |
||
| 150 | protected $registrants; |
||
| 151 | |||
| 152 | /** |
||
| 153 | * @var Recording[]|ArrayCollection |
||
| 154 | * |
||
| 155 | * @ORM\OneToMany(targetEntity="Recording", mappedBy="meeting", cascade={"persist"}, orphanRemoval=true) |
||
| 156 | */ |
||
| 157 | protected $recordings; |
||
| 158 | |||
| 159 | /** |
||
| 160 | * @var string|null |
||
| 161 | * |
||
| 162 | * @ORM\Column(type="string", name="account_email", nullable=true) |
||
| 163 | */ |
||
| 164 | protected $accountEmail; |
||
| 165 | |||
| 166 | /** |
||
| 167 | * @var SysAnnouncement|null |
||
| 168 | * |
||
| 169 | * @ORM\OneToOne(targetEntity="Chamilo\CoreBundle\Entity\SysAnnouncement") |
||
| 170 | * @ORM\JoinColumn(name="sys_announcement_id", referencedColumnName="id", onDelete="SET NULL") |
||
| 171 | */ |
||
| 172 | protected $sysAnnouncement; |
||
| 173 | |||
| 174 | public function __construct() |
||
| 175 | { |
||
| 176 | $this->registrants = new ArrayCollection(); |
||
| 177 | $this->recordings = new ArrayCollection(); |
||
| 178 | $this->activities = new ArrayCollection(); |
||
| 179 | $this->signAttendance = false; |
||
| 180 | $this->sysAnnouncement = null; |
||
| 181 | } |
||
| 182 | |||
| 183 | /** |
||
| 184 | * @return string |
||
| 185 | */ |
||
| 186 | public function __toString() |
||
| 187 | { |
||
| 188 | return sprintf('Meeting %d', $this->id); |
||
| 189 | } |
||
| 190 | |||
| 191 | /** |
||
| 192 | * @return int |
||
| 193 | */ |
||
| 194 | public function getId() |
||
| 195 | { |
||
| 196 | return $this->id; |
||
| 197 | } |
||
| 198 | |||
| 199 | /** |
||
| 200 | * @return int |
||
| 201 | */ |
||
| 202 | public function getMeetingId() |
||
| 203 | { |
||
| 204 | return $this->meetingId; |
||
| 205 | } |
||
| 206 | |||
| 207 | /** |
||
| 208 | * @param int $meetingId |
||
| 209 | * |
||
| 210 | * @return Meeting |
||
| 211 | */ |
||
| 212 | public function setMeetingId($meetingId) |
||
| 213 | { |
||
| 214 | $this->meetingId = $meetingId; |
||
| 215 | |||
| 216 | return $this; |
||
| 217 | } |
||
| 218 | |||
| 219 | /** |
||
| 220 | * @return User |
||
| 221 | */ |
||
| 222 | public function getUser() |
||
| 223 | { |
||
| 224 | return $this->user; |
||
| 225 | } |
||
| 226 | |||
| 227 | /** |
||
| 228 | * @return Course |
||
| 229 | */ |
||
| 230 | public function getCourse() |
||
| 231 | { |
||
| 232 | return $this->course; |
||
| 233 | } |
||
| 234 | |||
| 235 | /** |
||
| 236 | * @return Session |
||
| 237 | */ |
||
| 238 | public function getSession() |
||
| 239 | { |
||
| 240 | return $this->session; |
||
| 241 | } |
||
| 242 | |||
| 243 | /** |
||
| 244 | * @return Registrant[]|ArrayCollection |
||
| 245 | */ |
||
| 246 | public function getRegistrants() |
||
| 247 | { |
||
| 248 | return $this->registrants; |
||
| 249 | } |
||
| 250 | |||
| 251 | /** |
||
| 252 | * @return Recording[]|ArrayCollection |
||
| 253 | */ |
||
| 254 | public function getRecordings() |
||
| 255 | { |
||
| 256 | return $this->recordings; |
||
| 257 | } |
||
| 258 | |||
| 259 | /** |
||
| 260 | * @return MeetingActivity[]|ArrayCollection |
||
| 261 | */ |
||
| 262 | public function getActivities() |
||
| 263 | { |
||
| 264 | return $this->activities; |
||
| 265 | } |
||
| 266 | |||
| 267 | public function addActivity(MeetingActivity $activity) |
||
| 268 | { |
||
| 269 | $activity->setMeeting($this); |
||
| 270 | $this->activities[] = $activity; |
||
| 271 | } |
||
| 272 | |||
| 273 | /** |
||
| 274 | * @param MeetingActivity[]|ArrayCollection $activities |
||
| 275 | * |
||
| 276 | * @return Meeting |
||
| 277 | */ |
||
| 278 | public function setActivities($activities) |
||
| 279 | { |
||
| 280 | $this->activities = $activities; |
||
| 281 | |||
| 282 | return $this; |
||
| 283 | } |
||
| 284 | |||
| 285 | /** |
||
| 286 | * @ORM\PostLoad |
||
| 287 | * |
||
| 288 | * @throws Exception |
||
| 289 | */ |
||
| 290 | public function postLoad() |
||
| 291 | { |
||
| 292 | if (null !== $this->meetingListItemJson) { |
||
| 293 | $this->meetingListItem = MeetingListItem::fromJson($this->meetingListItemJson); |
||
| 294 | } |
||
| 295 | if (null !== $this->meetingInfoGetJson) { |
||
| 296 | $this->meetingInfoGet = MeetingInfoGet::fromJson($this->meetingInfoGetJson); |
||
| 297 | } |
||
| 298 | $this->initializeDisplayableProperties(); |
||
| 299 | } |
||
| 300 | |||
| 301 | /** |
||
| 302 | * @ORM\PostUpdate |
||
| 303 | * |
||
| 304 | * @throws Exception |
||
| 305 | */ |
||
| 306 | public function postUpdate() |
||
| 307 | { |
||
| 308 | $this->initializeDisplayableProperties(); |
||
| 309 | } |
||
| 310 | |||
| 311 | /** |
||
| 312 | * @ORM\PreFlush |
||
| 313 | */ |
||
| 314 | public function preFlush() |
||
| 315 | { |
||
| 316 | if (null !== $this->meetingListItem) { |
||
| 317 | $this->meetingListItemJson = json_encode($this->meetingListItem); |
||
| 318 | } |
||
| 319 | if (null !== $this->meetingInfoGet) { |
||
| 320 | $this->meetingInfoGetJson = json_encode($this->meetingInfoGet); |
||
| 321 | } |
||
| 322 | } |
||
| 323 | |||
| 324 | /** |
||
| 325 | * @return MeetingListItem |
||
| 326 | */ |
||
| 327 | public function getMeetingListItem() |
||
| 328 | { |
||
| 329 | return $this->meetingListItem; |
||
| 330 | } |
||
| 331 | |||
| 332 | /** |
||
| 333 | * @return MeetingInfoGet |
||
| 334 | */ |
||
| 335 | public function getMeetingInfoGet() |
||
| 336 | { |
||
| 337 | return $this->meetingInfoGet; |
||
| 338 | } |
||
| 339 | |||
| 340 | /** |
||
| 341 | * @param User $user |
||
| 342 | * |
||
| 343 | * @return $this |
||
| 344 | */ |
||
| 345 | public function setUser($user) |
||
| 346 | { |
||
| 347 | $this->user = $user; |
||
| 348 | |||
| 349 | return $this; |
||
| 350 | } |
||
| 351 | |||
| 352 | /** |
||
| 353 | * @param Course $course |
||
| 354 | * |
||
| 355 | * @return $this |
||
| 356 | */ |
||
| 357 | public function setCourse($course) |
||
| 358 | { |
||
| 359 | $this->course = $course; |
||
| 360 | |||
| 361 | return $this; |
||
| 362 | } |
||
| 363 | |||
| 364 | /** |
||
| 365 | * @param Session $session |
||
| 366 | * |
||
| 367 | * @return $this |
||
| 368 | */ |
||
| 369 | public function setSession($session) |
||
| 370 | { |
||
| 371 | $this->session = $session; |
||
| 372 | |||
| 373 | return $this; |
||
| 374 | } |
||
| 375 | |||
| 376 | /** |
||
| 377 | * @return CGroupInfo |
||
| 378 | */ |
||
| 379 | public function getGroup() |
||
| 380 | { |
||
| 381 | return $this->group; |
||
| 382 | } |
||
| 383 | |||
| 384 | /** |
||
| 385 | * @param CGroupInfo $group |
||
| 386 | * |
||
| 387 | * @return Meeting |
||
| 388 | */ |
||
| 389 | public function setGroup($group) |
||
| 390 | { |
||
| 391 | $this->group = $group; |
||
| 392 | |||
| 393 | return $this; |
||
| 394 | } |
||
| 395 | |||
| 396 | /** |
||
| 397 | * @param MeetingListItem $meetingListItem |
||
| 398 | * |
||
| 399 | * @throws Exception |
||
| 400 | * |
||
| 401 | * @return Meeting |
||
| 402 | */ |
||
| 403 | public function setMeetingListItem($meetingListItem) |
||
| 404 | { |
||
| 405 | if (null === $this->meetingId) { |
||
| 406 | $this->meetingId = $meetingListItem->id; |
||
|
|
|||
| 407 | } elseif ($this->meetingId != $meetingListItem->id) { |
||
| 408 | throw new Exception('the Meeting identifier differs from the MeetingListItem identifier'); |
||
| 409 | } |
||
| 410 | $this->meetingListItem = $meetingListItem; |
||
| 411 | |||
| 412 | return $this; |
||
| 413 | } |
||
| 414 | |||
| 415 | /** |
||
| 416 | * @param MeetingInfoGet|BaseMeetingTrait $meetingInfoGet |
||
| 417 | * |
||
| 418 | * @throws Exception |
||
| 419 | * |
||
| 420 | * @return Meeting |
||
| 421 | */ |
||
| 422 | public function setMeetingInfoGet($meetingInfoGet) |
||
| 423 | { |
||
| 424 | if (null === $this->meetingId) { |
||
| 425 | $this->meetingId = $meetingInfoGet->id; |
||
| 426 | } elseif ($this->meetingId != $meetingInfoGet->id) { |
||
| 427 | throw new Exception('the Meeting identifier differs from the MeetingInfoGet identifier'); |
||
| 428 | } |
||
| 429 | $this->meetingInfoGet = $meetingInfoGet; |
||
| 430 | $this->initializeDisplayableProperties(); |
||
| 431 | |||
| 432 | return $this; |
||
| 433 | } |
||
| 434 | |||
| 435 | /** |
||
| 436 | * @return bool |
||
| 437 | */ |
||
| 438 | public function isCourseMeeting() |
||
| 439 | { |
||
| 440 | return null !== $this->course; |
||
| 441 | } |
||
| 442 | |||
| 443 | /** |
||
| 444 | * @return bool |
||
| 445 | */ |
||
| 446 | public function isCourseGroupMeeting() |
||
| 449 | } |
||
| 450 | |||
| 451 | /** |
||
| 452 | * @return bool |
||
| 453 | */ |
||
| 454 | public function isUserMeeting() |
||
| 455 | { |
||
| 456 | return null !== $this->user && null === $this->course; |
||
| 457 | } |
||
| 458 | |||
| 459 | /** |
||
| 460 | * @return bool |
||
| 461 | */ |
||
| 462 | public function isGlobalMeeting() |
||
| 463 | { |
||
| 464 | return null === $this->user && null === $this->course; |
||
| 465 | } |
||
| 466 | |||
| 467 | public function setStatus($status) |
||
| 468 | { |
||
| 469 | $this->meetingInfoGet->status = $status; |
||
| 470 | } |
||
| 471 | |||
| 472 | /** |
||
| 473 | * Builds the list of users that can register into this meeting. |
||
| 474 | * Zoom requires an email address, therefore users without an email address are excluded from the list. |
||
| 475 | * |
||
| 476 | * @return User[] the list of users |
||
| 477 | */ |
||
| 478 | public function getRegistrableUsers() |
||
| 479 | { |
||
| 480 | $users = []; |
||
| 481 | if (!$this->isCourseMeeting()) { |
||
| 482 | $criteria = ['active' => true]; |
||
| 483 | $users = Database::getManager()->getRepository('ChamiloUserBundle:User')->findBy($criteria); |
||
| 484 | } elseif (null === $this->session) { |
||
| 485 | if (null !== $this->course) { |
||
| 486 | /** @var CourseRelUser $courseRelUser */ |
||
| 487 | foreach ($this->course->getUsers() as $courseRelUser) { |
||
| 488 | $users[] = $courseRelUser->getUser(); |
||
| 489 | } |
||
| 490 | } |
||
| 491 | } else { |
||
| 492 | if (null !== $this->course) { |
||
| 493 | $subscriptions = $this->session->getUserCourseSubscriptionsByStatus($this->course, Session::STUDENT); |
||
| 494 | if ($subscriptions) { |
||
| 495 | /** @var SessionRelCourseRelUser $sessionCourseUser */ |
||
| 496 | foreach ($subscriptions as $sessionCourseUser) { |
||
| 497 | $users[] = $sessionCourseUser->getUser(); |
||
| 498 | } |
||
| 499 | } |
||
| 500 | } |
||
| 501 | } |
||
| 502 | |||
| 503 | $activeUsersWithEmail = []; |
||
| 504 | foreach ($users as $user) { |
||
| 505 | if ($user->isActive() && !empty($user->getEmail())) { |
||
| 506 | $activeUsersWithEmail[] = $user; |
||
| 507 | } |
||
| 508 | } |
||
| 509 | |||
| 510 | return $activeUsersWithEmail; |
||
| 511 | } |
||
| 512 | |||
| 513 | /** |
||
| 514 | * @return bool |
||
| 515 | */ |
||
| 516 | public function requiresDateAndDuration() |
||
| 517 | { |
||
| 518 | return MeetingInfoGet::TYPE_SCHEDULED === $this->meetingInfoGet->type |
||
| 519 | || MeetingInfoGet::TYPE_RECURRING_WITH_FIXED_TIME === $this->meetingInfoGet->type; |
||
| 520 | } |
||
| 521 | |||
| 522 | public function requiresRegistration(): bool |
||
| 523 | { |
||
| 524 | return true; //MeetingSettings::APPROVAL_TYPE_AUTOMATICALLY_APPROVE === $this->meetingInfoGet->settings->approval_type; |
||
| 525 | /*return |
||
| 526 | MeetingSettings::APPROVAL_TYPE_NO_REGISTRATION_REQUIRED != $this->meetingInfoGet->settings->approval_type;*/ |
||
| 527 | } |
||
| 528 | |||
| 529 | /** |
||
| 530 | * @return bool |
||
| 531 | */ |
||
| 532 | public function hasCloudAutoRecordingEnabled() |
||
| 533 | { |
||
| 534 | return \ZoomPlugin::RECORDING_TYPE_NONE !== $this->meetingInfoGet->settings->auto_recording; |
||
| 535 | } |
||
| 536 | |||
| 537 | public function getRegistrantByUser(User $user): ?Registrant |
||
| 538 | { |
||
| 539 | $criteria = Criteria::create() |
||
| 540 | ->where( |
||
| 541 | Criteria::expr()->eq('user', $user) |
||
| 542 | ) |
||
| 543 | ; |
||
| 544 | |||
| 545 | return $this->registrants->matching($criteria)->first() ?: null; |
||
| 546 | } |
||
| 547 | |||
| 548 | /** |
||
| 549 | * Generates a short presentation of the meeting for the future participant. |
||
| 550 | * To be displayed above the "Enter meeting" link. |
||
| 551 | * |
||
| 552 | * @return string |
||
| 553 | */ |
||
| 554 | public function getIntroduction() |
||
| 555 | { |
||
| 556 | $introduction = sprintf('<h1>%s</h1>', $this->getTopic()).PHP_EOL; |
||
| 557 | if (!$this->isGlobalMeeting()) { |
||
| 558 | if (!empty($this->formattedStartTime)) { |
||
| 559 | $introduction .= $this->formattedStartTime; |
||
| 560 | if (!empty($this->formattedDuration)) { |
||
| 561 | $introduction .= ' ('.$this->formattedDuration.')'; |
||
| 562 | } |
||
| 563 | $introduction .= PHP_EOL; |
||
| 564 | } |
||
| 565 | } |
||
| 566 | if ($this->user) { |
||
| 567 | $introduction .= sprintf('<p>%s</p>', $this->user->getFullname()).PHP_EOL; |
||
| 568 | } elseif ($this->isCourseMeeting()) { |
||
| 569 | if (null === $this->session) { |
||
| 570 | $introduction .= sprintf('<p class="main">%s</p>', $this->course).PHP_EOL; |
||
| 571 | } else { |
||
| 572 | $introduction .= sprintf('<p class="main">%s (%s)</p>', $this->course, $this->session).PHP_EOL; |
||
| 573 | } |
||
| 574 | } |
||
| 575 | |||
| 576 | if (!empty($this->getAgenda())) { |
||
| 577 | $introduction .= sprintf('<p>%s</p>', $this->getAgenda()).PHP_EOL; |
||
| 578 | } |
||
| 579 | |||
| 580 | return $introduction; |
||
| 581 | } |
||
| 582 | |||
| 583 | public function isSignAttendance(): bool |
||
| 584 | { |
||
| 585 | return $this->signAttendance; |
||
| 586 | } |
||
| 587 | |||
| 588 | public function setSignAttendance(bool $signAttendance): Meeting |
||
| 589 | { |
||
| 590 | $this->signAttendance = $signAttendance; |
||
| 591 | |||
| 592 | return $this; |
||
| 593 | } |
||
| 594 | |||
| 595 | public function getAccountEmail(): ?string |
||
| 596 | { |
||
| 597 | return $this->accountEmail; |
||
| 598 | } |
||
| 599 | |||
| 600 | public function setAccountEmail(?string $accountEmail): self |
||
| 601 | { |
||
| 602 | $this->accountEmail = $accountEmail; |
||
| 603 | |||
| 604 | return $this; |
||
| 605 | } |
||
| 606 | |||
| 607 | public function getReasonToSignAttendance(): ?string |
||
| 610 | } |
||
| 611 | |||
| 612 | public function setReasonToSignAttendance(string $reasonToSignAttendance): Meeting |
||
| 613 | { |
||
| 614 | $this->reasonToSignAttendance = $reasonToSignAttendance; |
||
| 615 | |||
| 616 | return $this; |
||
| 617 | } |
||
| 618 | |||
| 619 | public function getTopic(): string |
||
| 620 | { |
||
| 621 | return $this->meetingInfoGet->topic; |
||
| 622 | } |
||
| 623 | |||
| 624 | public function getAgenda(): ?string |
||
| 625 | { |
||
| 626 | return $this->meetingInfoGet->agenda; |
||
| 627 | } |
||
| 628 | |||
| 629 | public function getSysAnnouncement(): ?SysAnnouncement |
||
| 630 | { |
||
| 631 | return $this->sysAnnouncement; |
||
| 632 | } |
||
| 633 | |||
| 634 | public function setSysAnnouncement(?SysAnnouncement $sysAnnouncement): Meeting |
||
| 639 | } |
||
| 640 | |||
| 641 | /** |
||
| 642 | * @throws Exception on unexpected start_time or duration |
||
| 643 | */ |
||
| 644 | protected function initializeDisplayableProperties() |
||
| 645 | { |
||
| 646 | $zoomPlugin = new \ZoomPlugin(); |
||
| 647 | |||
| 680 | } |
||
| 681 | } |
||
| 682 | } |
||
| 683 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.