name ) ) { throw new DomainException( 'extra.name_empty', 'Extra name must not be empty.' ); } if ( $this->duration_min < 0 ) { throw new DomainException( 'extra.duration_negative', 'Extra duration must not be negative.' ); } if ( $this->max_quantity < 1 ) { throw new DomainException( 'extra.max_quantity', 'max_quantity must be at least 1.' ); } if ( $this->price->is_negative() ) { throw new DomainException( 'extra.price_negative', 'Extra price must not be negative.' ); } } /** * Database id. * * @since 0.1.0 */ public function id(): ?int { return $this->id; } /** * Public UUID. * * @since 0.1.0 */ public function uuid(): Uuid { return $this->uuid; } /** * Name. * * @since 0.1.0 */ public function name(): string { return $this->name; } /** * Description. * * @since 0.1.0 */ public function description(): ?string { return $this->description; } /** * Price. * * @since 0.1.0 */ public function price(): Money { return $this->price; } /** * Duration min. * * @since 0.1.0 */ public function duration_min(): int { return $this->duration_min; } /** * Max quantity. * * @since 0.1.0 */ public function max_quantity(): int { return $this->max_quantity; } /** * Image id. * * @since 0.1.0 */ public function image_id(): ?int { return $this->image_id; } /** * Status. * * @since 0.1.0 */ public function status(): ServiceExtraStatus { return $this->status; } /** * Sort order. * * @since 0.1.0 */ public function sort_order(): int { return $this->sort_order; } /** * Created at. * * @since 0.1.0 */ public function created_at(): DateTimeImmutable { return $this->created_at; } /** * Updated at. * * @since 0.1.0 */ public function updated_at(): DateTimeImmutable { return $this->updated_at; } /** * Assign the database id after insert. * * @param int $id New id. * * @throws \Bookline\Domain\Shared\DomainException When id is already set or invalid. * * @since 0.1.0 */ public function assign_id( int $id ): void { if ( null !== $this->id ) { throw new DomainException( 'extra.id_assigned', 'Extra id is already assigned.' ); } $this->id = $id; } }