mirror of
https://github.com/anthonyaxenov/atol-online.git
synced 2024-12-22 15:14:57 +00:00
Улучшен класс Company
* valid_strlen() * Constraints::MAX_LENGTH_PAYMENT_ADDRESS * phpdoc
This commit is contained in:
parent
8eb309bc58
commit
2943d93962
@ -9,7 +9,8 @@
|
||||
|
||||
namespace AtolOnline\Entities;
|
||||
|
||||
use AtolOnline\{Exceptions\AtolEmailTooLongException,
|
||||
use AtolOnline\{Constants\Constraints,
|
||||
Exceptions\AtolEmailTooLongException,
|
||||
Exceptions\AtolEmailValidateException,
|
||||
Exceptions\AtolInnWrongLengthException,
|
||||
Exceptions\AtolPaymentAddressTooLongException,
|
||||
@ -52,10 +53,10 @@ class Company extends Entity
|
||||
* @param string|null $inn
|
||||
* @param string|null $paymentAddress
|
||||
* @param string|null $email
|
||||
* @throws AtolEmailTooLongException
|
||||
* @throws AtolEmailValidateException
|
||||
* @throws AtolInnWrongLengthException
|
||||
* @throws AtolPaymentAddressTooLongException
|
||||
* @throws AtolEmailTooLongException Слишком длинный email
|
||||
* @throws AtolEmailValidateException Невалидный email
|
||||
* @throws AtolInnWrongLengthException Некорректная длина ИНН
|
||||
* @throws AtolPaymentAddressTooLongException Слишком длинный адрес места расчётов
|
||||
*/
|
||||
public function __construct(string $sno = null, string $inn = null, string $paymentAddress = null, string $email = null)
|
||||
{
|
||||
@ -110,13 +111,13 @@ class Company extends Entity
|
||||
*
|
||||
* @param string $payment_address
|
||||
* @return $this
|
||||
* @throws AtolPaymentAddressTooLongException
|
||||
* @throws AtolPaymentAddressTooLongException Слишком длинный адрес места расчётов
|
||||
*/
|
||||
public function setPaymentAddress(string $payment_address)
|
||||
{
|
||||
$payment_address = trim($payment_address);
|
||||
if ((function_exists('mb_strlen') ? mb_strlen($payment_address) : strlen($payment_address)) > 256) {
|
||||
throw new AtolPaymentAddressTooLongException($payment_address, 256);
|
||||
if (valid_strlen($payment_address) > Constraints::MAX_LENGTH_PAYMENT_ADDRESS) {
|
||||
throw new AtolPaymentAddressTooLongException($payment_address, Constraints::MAX_LENGTH_PAYMENT_ADDRESS);
|
||||
}
|
||||
$this->payment_address = $payment_address;
|
||||
return $this;
|
||||
|
Loading…
Reference in New Issue
Block a user