From 8eb309bc58fb8493982dcbc436584df09764de12 Mon Sep 17 00:00:00 2001 From: AnthonyAxenov Date: Sun, 7 Jun 2020 19:27:15 +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=20=D0=A1lient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * valid_strlen() * Constraints::MAX_LENGTH_CLIENT_NAME * Constraints::MAX_LENGTH_CLIENT_PHONE * phpdoc --- src/AtolOnline/Entities/Client.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/AtolOnline/Entities/Client.php b/src/AtolOnline/Entities/Client.php index 141b765..0feca75 100644 --- a/src/AtolOnline/Entities/Client.php +++ b/src/AtolOnline/Entities/Client.php @@ -9,7 +9,7 @@ namespace AtolOnline\Entities; -use AtolOnline\{Exceptions\AtolNameTooLongException, Exceptions\AtolPhoneTooLongException, Traits\HasEmail, Traits\HasInn}; +use AtolOnline\{Constants\Constraints, Exceptions\AtolNameTooLongException, Exceptions\AtolPhoneTooLongException, Traits\HasEmail, Traits\HasInn}; /** * Класс Client, описывающий сущность покупателя @@ -46,11 +46,11 @@ class Client extends Entity * @param string|null $phone Телефон * @param string|null $email Email * @param string|null $inn ИНН - * @throws \AtolOnline\Exceptions\AtolEmailTooLongException - * @throws \AtolOnline\Exceptions\AtolEmailValidateException - * @throws \AtolOnline\Exceptions\AtolInnWrongLengthException - * @throws \AtolOnline\Exceptions\AtolNameTooLongException - * @throws \AtolOnline\Exceptions\AtolPhoneTooLongException + * @throws \AtolOnline\Exceptions\AtolEmailTooLongException Слишком длинный email + * @throws \AtolOnline\Exceptions\AtolEmailValidateException Невалидный email + * @throws \AtolOnline\Exceptions\AtolInnWrongLengthException Некорректная длина ИНН + * @throws \AtolOnline\Exceptions\AtolNameTooLongException Слишком длинное имя + * @throws \AtolOnline\Exceptions\AtolPhoneTooLongException СЛишком длинный номер телефона */ public function __construct(?string $name = null, ?string $phone = null, ?string $email = null, ?string $inn = null) { @@ -89,8 +89,8 @@ class Client extends Entity public function setName(string $name) { $name = trim($name); - if ((function_exists('mb_strlen') ? mb_strlen($name) : strlen($name)) > 256) { - throw new AtolNameTooLongException($name, 256); + if (valid_strlen($name) > Constraints::MAX_LENGTH_CLIENT_NAME) { + throw new AtolNameTooLongException($name, Constraints::MAX_LENGTH_CLIENT_NAME); } $this->name = $name; return $this; @@ -119,8 +119,8 @@ class Client extends Entity public function setPhone(string $phone) { $phone = preg_replace("/[^0-9+]/", '', $phone); - if ((function_exists('mb_strlen') ? mb_strlen($phone) : strlen($phone)) > 64) { - throw new AtolPhoneTooLongException($phone, 64); + if (valid_strlen($phone) > Constraints::MAX_LENGTH_CLIENT_PHONE) { + throw new AtolPhoneTooLongException($phone, Constraints::MAX_LENGTH_CLIENT_PHONE); } $this->phone = $phone; return $this;