setName($name)->setValue($value); } /** * Возвращает наименование реквизита * * @return string */ public function getName(): string { return $this->name; } /** * Устанавливает наименование реквизита * * @param string $name * @return $this * @throws TooLongAddUserPropNameException * @throws EmptyAddUserPropNameException */ public function setName(string $name): self { $name = trim($name); if (mb_strlen($name) > Constraints::MAX_LENGTH_ADD_USER_PROP_NAME) { throw new TooLongAddUserPropNameException($name); } if (empty($name)) { throw new EmptyAddUserPropNameException($name); } $this->name = $name; return $this; } /** * Возвращает установленный телефон * * @return string|null */ public function getValue(): ?string { return $this->value; } /** * Устанавливает значение реквизита * * @param string $value * @return $this * @throws TooLongAddUserPropValueException * @throws EmptyAddUserPropValueException */ public function setValue(string $value): self { $value = trim($value); if (mb_strlen($value) > Constraints::MAX_LENGTH_CLIENT_NAME) { throw new TooLongAddUserPropValueException($value); } if (empty($value)) { throw new EmptyAddUserPropValueException($value); } $this->value = $value; return $this; } /** * @inheritDoc */ #[Pure] #[ArrayShape(['name' => 'string', 'value' => 'null|string'])] public function jsonSerialize(): array { return [ 'name' => $this->getName(), 'value' => $this->getValue(), ]; } }