setEmail($email); $this->setSno($sno); $this->setInn($inn); $this->setPaymentAddress($payment_address); } /** * Возвращает установленный тип налогообложения * * @return string */ public function getSno(): string { return $this->sno; } /** * Устанавливает тип налогообложения * * @param string $sno * @return $this * @throws InvalidEnumValueException */ public function setSno(string $sno): self { $sno = trim($sno); SnoTypes::isValid($sno); $this->sno = $sno; return $this; } /** * Возвращает установленный адрес места расчётов * * @return string */ public function getPaymentAddress(): string { return $this->payment_address; } /** * Устанавливает адрес места расчётов * * @param string $payment_address * @return $this * @throws TooLongPaymentAddressException * @throws InvalidPaymentAddressException */ public function setPaymentAddress(string $payment_address): self { $payment_address = trim($payment_address); if (empty($payment_address)) { throw new InvalidPaymentAddressException(); } elseif (mb_strlen($payment_address) > Constraints::MAX_LENGTH_PAYMENT_ADDRESS) { throw new TooLongPaymentAddressException($payment_address); } $this->payment_address = $payment_address; return $this; } /** * @inheritDoc * @throws InvalidEmailException * @throws InvalidEnumValueException * @throws InvalidInnLengthException * @throws InvalidPaymentAddressException */ #[ArrayShape([ 'email' => "string", 'sno' => "string", 'inn' => "string", 'payment_address' => "string", ])] public function jsonSerialize(): array { return [ 'email' => $this->email ? $this->getEmail() : throw new InvalidEmailException(), 'sno' => $this->sno ? $this->getSno() : throw new InvalidEnumValueException(SnoTypes::class, 'null'), 'inn' => $this->inn ? $this->getInn() : throw new InvalidInnLengthException(), 'payment_address' => $this->payment_address ? $this->getPaymentAddress() : throw new InvalidPaymentAddressException(), ]; } }