From 2943d939629bdf1ebbbb8c1227a347d8bd8af224 Mon Sep 17 00:00:00 2001 From: AnthonyAxenov Date: Sun, 7 Jun 2020 19:27:49 +0800 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20Company?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * valid_strlen() * Constraints::MAX_LENGTH_PAYMENT_ADDRESS * phpdoc --- src/AtolOnline/Entities/Company.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/AtolOnline/Entities/Company.php b/src/AtolOnline/Entities/Company.php index 289e706..97b3e69 100644 --- a/src/AtolOnline/Entities/Company.php +++ b/src/AtolOnline/Entities/Company.php @@ -9,7 +9,8 @@ namespace AtolOnline\Entities; -use AtolOnline\{Exceptions\AtolEmailTooLongException, +use AtolOnline\{Constants\Constraints, + Exceptions\AtolEmailTooLongException, Exceptions\AtolEmailValidateException, Exceptions\AtolInnWrongLengthException, Exceptions\AtolPaymentAddressTooLongException, @@ -52,10 +53,10 @@ class Company extends Entity * @param string|null $inn * @param string|null $paymentAddress * @param string|null $email - * @throws AtolEmailTooLongException - * @throws AtolEmailValidateException - * @throws AtolInnWrongLengthException - * @throws AtolPaymentAddressTooLongException + * @throws AtolEmailTooLongException Слишком длинный email + * @throws AtolEmailValidateException Невалидный email + * @throws AtolInnWrongLengthException Некорректная длина ИНН + * @throws AtolPaymentAddressTooLongException Слишком длинный адрес места расчётов */ public function __construct(string $sno = null, string $inn = null, string $paymentAddress = null, string $email = null) { @@ -110,13 +111,13 @@ class Company extends Entity * * @param string $payment_address * @return $this - * @throws AtolPaymentAddressTooLongException + * @throws AtolPaymentAddressTooLongException Слишком длинный адрес места расчётов */ public function setPaymentAddress(string $payment_address) { $payment_address = trim($payment_address); - if ((function_exists('mb_strlen') ? mb_strlen($payment_address) : strlen($payment_address)) > 256) { - throw new AtolPaymentAddressTooLongException($payment_address, 256); + if (valid_strlen($payment_address) > Constraints::MAX_LENGTH_PAYMENT_ADDRESS) { + throw new AtolPaymentAddressTooLongException($payment_address, Constraints::MAX_LENGTH_PAYMENT_ADDRESS); } $this->payment_address = $payment_address; return $this;