From 9bd99c81a98d395f68a00160ac2004f7a15e30a0 Mon Sep 17 00:00:00 2001 From: AnthonyAxenov Date: Sun, 7 Jun 2020 19:28:55 +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=20Document?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * валидация в setCashier() только если передан не-null * valid_strlen() * Constraints::MAX_LENGTH_CASHIER_NAME * phpdoc --- src/AtolOnline/Entities/Document.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/AtolOnline/Entities/Document.php b/src/AtolOnline/Entities/Document.php index f3eaaae..4134d51 100644 --- a/src/AtolOnline/Entities/Document.php +++ b/src/AtolOnline/Entities/Document.php @@ -9,6 +9,7 @@ namespace AtolOnline\Entities; +use AtolOnline\Constants\Constraints; use AtolOnline\Exceptions\AtolCashierTooLongException; use AtolOnline\Exceptions\AtolException; use AtolOnline\Exceptions\AtolInvalidJsonException; @@ -259,9 +260,11 @@ class Document extends Entity */ public function setCashier(?string $cashier) { - $cashier = trim($cashier); - if ((function_exists('mb_strlen') ? mb_strlen($cashier) : strlen($cashier)) > 64) { - throw new AtolCashierTooLongException($cashier, 64); + if ($cashier !== null) { + $cashier = trim($cashier); + if (valid_strlen($cashier) > Constraints::MAX_LENGTH_CASHIER_NAME) { + throw new AtolCashierTooLongException($cashier, Constraints::MAX_LENGTH_CASHIER_NAME); + } } $this->cashier = $cashier; return $this;