mirror of
https://github.com/anthonyaxenov/atol-online.git
synced 2024-11-25 15:14:07 +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;
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user