*/ public const VALID_STATUSES = [ self::STATUS_ACTIVE, self::STATUS_CANCELLED, self::STATUS_COMPLETED ]; public function __construct( public readonly int $offeringId, public readonly int $studentId, public readonly int $instructorId, public readonly string $status = self::STATUS_ACTIVE, public readonly ?int $paymentId = null, public readonly ?int $id = null, ) {} public static function fromRow( object $row ): self { return new self( offeringId: (int) $row->offering_id, studentId: (int) $row->student_id, instructorId: (int) $row->instructor_id, status: $row->status, paymentId: null !== $row->payment_id ? (int) $row->payment_id : null, id: (int) $row->id, ); } /** * Returns a plain array representation of the enrolment. * * @return array */ public function toArray(): array { return [ 'id' => $this->id, 'offering_id' => $this->offeringId, 'student_id' => $this->studentId, 'instructor_id' => $this->instructorId, 'status' => $this->status, 'payment_id' => $this->paymentId, ]; } }