Улучшен класс Document
* валидация в setCashier() только если передан не-null * valid_strlen() * Constraints::MAX_LENGTH_CASHIER_NAME * phpdoc
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
namespace AtolOnline\Entities;
|
namespace AtolOnline\Entities;
|
||||||
|
|
||||||
|
use AtolOnline\Constants\Constraints;
|
||||||
use AtolOnline\Exceptions\AtolCashierTooLongException;
|
use AtolOnline\Exceptions\AtolCashierTooLongException;
|
||||||
use AtolOnline\Exceptions\AtolException;
|
use AtolOnline\Exceptions\AtolException;
|
||||||
use AtolOnline\Exceptions\AtolInvalidJsonException;
|
use AtolOnline\Exceptions\AtolInvalidJsonException;
|
||||||
@@ -259,9 +260,11 @@ class Document extends Entity
|
|||||||
*/
|
*/
|
||||||
public function setCashier(?string $cashier)
|
public function setCashier(?string $cashier)
|
||||||
{
|
{
|
||||||
$cashier = trim($cashier);
|
if ($cashier !== null) {
|
||||||
if ((function_exists('mb_strlen') ? mb_strlen($cashier) : strlen($cashier)) > 64) {
|
$cashier = trim($cashier);
|
||||||
throw new AtolCashierTooLongException($cashier, 64);
|
if (valid_strlen($cashier) > Constraints::MAX_LENGTH_CASHIER_NAME) {
|
||||||
|
throw new AtolCashierTooLongException($cashier, Constraints::MAX_LENGTH_CASHIER_NAME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->cashier = $cashier;
|
$this->cashier = $cashier;
|
||||||
return $this;
|
return $this;
|
||||||
|
|||||||
Reference in New Issue
Block a user