AgentInfo: перенос валидации типа агента из конструктора в сеттер

This commit is contained in:
Anthony Axenov 2021-11-28 00:44:43 +08:00
parent f548032843
commit 9d2617858d

View File

@ -56,7 +56,7 @@ class AgentInfo extends Entity
?ReceivePaymentsOperator $receive_payments_operator = null, ?ReceivePaymentsOperator $receive_payments_operator = null,
?MoneyTransferOperator $money_transfer_operator = null, ?MoneyTransferOperator $money_transfer_operator = null,
) { ) {
!is_null($type) && AgentTypes::isValid($type) && $this->setType($type); !is_null($type) && $this->setType($type);
!is_null($paying_agent) && $this->setPayingAgent($paying_agent); !is_null($paying_agent) && $this->setPayingAgent($paying_agent);
!is_null($receive_payments_operator) && $this->setReceivePaymentsOperator($receive_payments_operator); !is_null($receive_payments_operator) && $this->setReceivePaymentsOperator($receive_payments_operator);
!is_null($money_transfer_operator) && $this->setMoneyTransferOperator($money_transfer_operator); !is_null($money_transfer_operator) && $this->setMoneyTransferOperator($money_transfer_operator);
@ -77,10 +77,11 @@ class AgentInfo extends Entity
* *
* @param string|null $type * @param string|null $type
* @return AgentInfo * @return AgentInfo
* @throws InvalidEnumValueException
*/ */
public function setType(?string $type): AgentInfo public function setType(?string $type): AgentInfo
{ {
$this->type = $type; AgentTypes::isValid($type) && $this->type = $type;
return $this; return $this;
} }