*/ 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( \stdClass $row ): self { return new self( offeringId: Val::int( $row->offering_id ), studentId: Val::int( $row->student_id ), instructorId: Val::int( $row->instructor_id ), status: Val::string( $row->status ), paymentId: Val::intOrNull( $row->payment_id ), id: Val::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, ]; } }