mirror of
https://github.com/anthonyaxenov/atol-online.git
synced 2024-11-25 19:54:19 +00:00
Улучшен класс Document
* валидация в setCashier() только если передан не-null * valid_strlen() * Constraints::MAX_LENGTH_CASHIER_NAME * phpdoc
This commit is contained in:
parent
2943d93962
commit
9bd99c81a9
@ -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)
|
||||||
{
|
{
|
||||||
|
if ($cashier !== null) {
|
||||||
$cashier = trim($cashier);
|
$cashier = trim($cashier);
|
||||||
if ((function_exists('mb_strlen') ? mb_strlen($cashier) : strlen($cashier)) > 64) {
|
if (valid_strlen($cashier) > Constraints::MAX_LENGTH_CASHIER_NAME) {
|
||||||
throw new AtolCashierTooLongException($cashier, 64);
|
throw new AtolCashierTooLongException($cashier, Constraints::MAX_LENGTH_CASHIER_NAME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->cashier = $cashier;
|
$this->cashier = $cashier;
|
||||||
return $this;
|
return $this;
|
||||||
|
Loading…
Reference in New Issue
Block a user