Туча доработок
- класс `PayingAgent`, покрытый тестами - новые константы для тегов ФФД 1.05 `Ffd105Tags` - `Entity::jsonSerialize()` object -> array (again) - `TooManyException::$max` int -> float - тесты по psr-4, потому что почему бы и нет - некоторые провайдеры вынесены в `BasicTestCase` - улучшен тест покупателя
This commit is contained in:
@@ -11,12 +11,18 @@ declare(strict_types = 1);
|
||||
|
||||
namespace AtolOnline\Exceptions;
|
||||
|
||||
use AtolOnline\Constants\Ffd105Tags;
|
||||
|
||||
/**
|
||||
* Исключение, возникающее при попытке указать пустой email
|
||||
*
|
||||
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 17
|
||||
*/
|
||||
class EmptyEmailException extends AtolException
|
||||
{
|
||||
protected $message = 'Email не может быть пустым';
|
||||
protected array $ffd_tags = [1008, 1117];
|
||||
protected array $ffd_tags = [
|
||||
Ffd105Tags::CLIENT_CONTACT,
|
||||
Ffd105Tags::COMPANY_EMAIL,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -11,13 +11,19 @@ declare(strict_types = 1);
|
||||
|
||||
namespace AtolOnline\Exceptions;
|
||||
|
||||
use AtolOnline\Constants\Ffd105Tags;
|
||||
|
||||
/**
|
||||
* Исключение, возникающее при ошибке валидации email
|
||||
*
|
||||
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 17
|
||||
*/
|
||||
class InvalidEmailException extends AtolException
|
||||
{
|
||||
protected array $ffd_tags = [1008, 1117];
|
||||
protected array $ffd_tags = [
|
||||
Ffd105Tags::CLIENT_CONTACT,
|
||||
Ffd105Tags::COMPANY_EMAIL,
|
||||
];
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
|
||||
@@ -11,12 +11,19 @@ declare(strict_types = 1);
|
||||
|
||||
namespace AtolOnline\Exceptions;
|
||||
|
||||
use AtolOnline\Constants\Ffd105Tags;
|
||||
|
||||
/**
|
||||
* Исключение, возникающее при попытке указать ИНН некорректной длины
|
||||
*/
|
||||
class InvalidInnLengthException extends AtolException
|
||||
{
|
||||
protected array $ffd_tags = [1016, 1018, 1226, 1228];
|
||||
protected array $ffd_tags = [
|
||||
Ffd105Tags::MTO_INN,
|
||||
Ffd105Tags::COMPANY_INN,
|
||||
Ffd105Tags::SUPPLIER_INN,
|
||||
Ffd105Tags::CLIENT_INN,
|
||||
];
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
|
||||
@@ -11,13 +11,16 @@ declare(strict_types = 1);
|
||||
|
||||
namespace AtolOnline\Exceptions;
|
||||
|
||||
use AtolOnline\Constants\Ffd105Tags;
|
||||
|
||||
/**
|
||||
* Исключение, возникающее при попытке указать некорректный адрес места расчётов
|
||||
*
|
||||
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 35
|
||||
*/
|
||||
class InvalidPaymentAddressException extends AtolException
|
||||
{
|
||||
protected array $ffd_tags = [1187];
|
||||
protected array $ffd_tags = [Ffd105Tags::COMPANY_PADDRESS];
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
|
||||
35
src/Exceptions/InvalidPhoneException.php
Normal file
35
src/Exceptions/InvalidPhoneException.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
|
||||
*
|
||||
* This code is licensed under MIT.
|
||||
* Этот код распространяется по лицензии MIT.
|
||||
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace AtolOnline\Exceptions;
|
||||
|
||||
use AtolOnline\Constants\Ffd105Tags;
|
||||
|
||||
/**
|
||||
* Исключение, возникающее при ошибке валидации телефона
|
||||
*/
|
||||
class InvalidPhoneException extends AtolException
|
||||
{
|
||||
protected array $ffd_tags = [
|
||||
Ffd105Tags::CLIENT_CONTACT,
|
||||
Ffd105Tags::PAGENT_PHONE,
|
||||
];
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
*
|
||||
* @param string $phone
|
||||
*/
|
||||
public function __construct(string $phone = '')
|
||||
{
|
||||
parent::__construct("Невалидный номер телефона: '$phone'");
|
||||
}
|
||||
}
|
||||
@@ -11,20 +11,15 @@ declare(strict_types = 1);
|
||||
|
||||
namespace AtolOnline\Exceptions;
|
||||
|
||||
use AtolOnline\Constants\Constraints;
|
||||
use AtolOnline\Constants\Ffd105Tags;
|
||||
|
||||
/**
|
||||
* Исключение, возникающее при попытке указать слишком высокую цену (сумму)
|
||||
*/
|
||||
class TooHighPriceException extends TooManyException
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected array $ffd_tags = [
|
||||
1079,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string Сообщение об ошибке
|
||||
*/
|
||||
protected $message = 'Price is too high';
|
||||
}
|
||||
protected $message = 'Слишком высокая цена';
|
||||
protected array $ffd_tags = [Ffd105Tags::ITEM_PRICE];
|
||||
protected float $max = Constraints::MAX_COUNT_ITEM_PRICE;
|
||||
}
|
||||
|
||||
@@ -19,5 +19,5 @@ use AtolOnline\Constants\Constraints;
|
||||
class TooLongCallbackUrlException extends TooLongException
|
||||
{
|
||||
protected $message = 'Слишком длинный адрес колбека';
|
||||
protected int $max = Constraints::MAX_LENGTH_CALLBACK_URL;
|
||||
protected float $max = Constraints::MAX_LENGTH_CALLBACK_URL;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ declare(strict_types = 1);
|
||||
namespace AtolOnline\Exceptions;
|
||||
|
||||
use AtolOnline\Constants\Constraints;
|
||||
use AtolOnline\Constants\Ffd105Tags;
|
||||
|
||||
/**
|
||||
* Исключение, возникающее при попытке указать слишком длинное имя кассира
|
||||
@@ -19,6 +20,6 @@ use AtolOnline\Constants\Constraints;
|
||||
class TooLongCashierException extends TooLongException
|
||||
{
|
||||
protected $message = 'Слишком длинное имя кассира';
|
||||
protected int $max = Constraints::MAX_LENGTH_CASHIER_NAME;
|
||||
protected array $ffd_tags = [1021];
|
||||
protected float $max = Constraints::MAX_LENGTH_CASHIER_NAME;
|
||||
protected array $ffd_tags = [Ffd105Tags::CASHIER];
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ declare(strict_types = 1);
|
||||
namespace AtolOnline\Exceptions;
|
||||
|
||||
use AtolOnline\Constants\Constraints;
|
||||
use AtolOnline\Constants\Ffd105Tags;
|
||||
|
||||
/**
|
||||
* Исключение, возникающее при попытке указать слишком длинный телефон или email покупателя
|
||||
@@ -19,6 +20,6 @@ use AtolOnline\Constants\Constraints;
|
||||
class TooLongClientContactException extends TooLongException
|
||||
{
|
||||
protected $message = 'Cлишком длинный телефон или email покупателя';
|
||||
protected int $max = Constraints::MAX_LENGTH_CLIENT_CONTACT;
|
||||
protected array $ffd_tags = [1008];
|
||||
protected float $max = Constraints::MAX_LENGTH_CLIENT_CONTACT;
|
||||
protected array $ffd_tags = [Ffd105Tags::CLIENT_CONTACT];
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ declare(strict_types = 1);
|
||||
namespace AtolOnline\Exceptions;
|
||||
|
||||
use AtolOnline\Constants\Constraints;
|
||||
use AtolOnline\Constants\Ffd105Tags;
|
||||
|
||||
/**
|
||||
* Исключение, возникающее при попытке указать слишком длинное наименование покупателя
|
||||
@@ -19,6 +20,6 @@ use AtolOnline\Constants\Constraints;
|
||||
class TooLongClientNameException extends TooLongException
|
||||
{
|
||||
protected $message = 'Cлишком длинное наименование покупателя';
|
||||
protected int $max = Constraints::MAX_LENGTH_CLIENT_NAME;
|
||||
protected array $ffd_tags = [1227];
|
||||
protected float $max = Constraints::MAX_LENGTH_CLIENT_NAME;
|
||||
protected array $ffd_tags = [Ffd105Tags::CLIENT_NAME];
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ declare(strict_types = 1);
|
||||
namespace AtolOnline\Exceptions;
|
||||
|
||||
use AtolOnline\Constants\Constraints;
|
||||
use AtolOnline\Constants\Ffd105Tags;
|
||||
|
||||
/**
|
||||
* Исключение, возникающее при попытке указать слишком длинный email
|
||||
@@ -19,6 +20,9 @@ use AtolOnline\Constants\Constraints;
|
||||
class TooLongEmailException extends TooLongException
|
||||
{
|
||||
protected $message = 'Слишком длинный email';
|
||||
protected int $max = Constraints::MAX_LENGTH_EMAIL;
|
||||
protected array $ffd_tags = [1008, 1117];
|
||||
protected float $max = Constraints::MAX_LENGTH_EMAIL;
|
||||
protected array $ffd_tags = [
|
||||
Ffd105Tags::CLIENT_CONTACT,
|
||||
Ffd105Tags::COMPANY_EMAIL,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ class TooLongException extends AtolException
|
||||
protected $message = 'Слишком длинное значение';
|
||||
|
||||
/**
|
||||
* @var int Максимальная длина строки
|
||||
* @var float Максимальная длина строки
|
||||
*/
|
||||
protected int $max = 0;
|
||||
protected float $max = 0;
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
|
||||
@@ -11,7 +11,10 @@ declare(strict_types = 1);
|
||||
|
||||
namespace AtolOnline\Exceptions;
|
||||
|
||||
use AtolOnline\Constants\Constraints;
|
||||
use AtolOnline\Constants\{
|
||||
Constraints,
|
||||
Ffd105Tags
|
||||
};
|
||||
|
||||
/**
|
||||
* Исключение, возникающее при попытке указать слишком длинное имя
|
||||
@@ -19,6 +22,6 @@ use AtolOnline\Constants\Constraints;
|
||||
class TooLongItemNameException extends TooLongException
|
||||
{
|
||||
protected $message = 'Слишком длинное наименование предмета расчёта';
|
||||
protected int $max = Constraints::MAX_LENGTH_ITEM_NAME;
|
||||
protected array $ffd_tags = [1030];
|
||||
protected float $max = Constraints::MAX_LENGTH_ITEM_NAME;
|
||||
protected array $ffd_tags = [Ffd105Tags::ITEM_NAME];
|
||||
}
|
||||
|
||||
@@ -19,5 +19,5 @@ use AtolOnline\Constants\Constraints;
|
||||
class TooLongLoginException extends TooLongException
|
||||
{
|
||||
protected $message = 'Слишком длинный логин';
|
||||
protected int $max = Constraints::MAX_LENGTH_LOGIN;
|
||||
protected float $max = Constraints::MAX_LENGTH_LOGIN;
|
||||
}
|
||||
|
||||
@@ -19,5 +19,5 @@ use AtolOnline\Constants\Constraints;
|
||||
class TooLongPasswordException extends TooLongException
|
||||
{
|
||||
protected $message = 'Слишком длинный пароль';
|
||||
protected int $max = Constraints::MAX_LENGTH_PASSWORD;
|
||||
protected float $max = Constraints::MAX_LENGTH_PASSWORD;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,10 @@ declare(strict_types = 1);
|
||||
|
||||
namespace AtolOnline\Exceptions;
|
||||
|
||||
use AtolOnline\Constants\Constraints;
|
||||
use AtolOnline\Constants\{
|
||||
Constraints,
|
||||
Ffd105Tags
|
||||
};
|
||||
|
||||
/**
|
||||
* Исключение, возникающее при попытке указать слишком длинную операцию для платёжного агента
|
||||
@@ -19,6 +22,6 @@ use AtolOnline\Constants\Constraints;
|
||||
class TooLongPayingAgentOperationException extends TooLongException
|
||||
{
|
||||
protected $message = 'Слишком длинное yаименование операции платёжного агента';
|
||||
protected int $max = Constraints::MAX_LENGTH_PAYING_AGENT_OPERATION;
|
||||
protected array $ffd_tags = [1073];
|
||||
protected float $max = Constraints::MAX_LENGTH_PAYING_AGENT_OPERATION;
|
||||
protected array $ffd_tags = [Ffd105Tags::PAGENT_PHONE];
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ declare(strict_types = 1);
|
||||
namespace AtolOnline\Exceptions;
|
||||
|
||||
use AtolOnline\Constants\Constraints;
|
||||
use AtolOnline\Constants\Ffd105Tags;
|
||||
|
||||
/**
|
||||
* Исключение, возникающее при попытке указать слишком длинный адрес места расчётов
|
||||
@@ -19,6 +20,6 @@ use AtolOnline\Constants\Constraints;
|
||||
class TooLongPaymentAddressException extends TooLongException
|
||||
{
|
||||
protected $message = 'Слишком длинный адрес места расчётов';
|
||||
protected int $max = Constraints::MAX_LENGTH_PAYMENT_ADDRESS;
|
||||
protected array $ffd_tags = [1187];
|
||||
protected float $max = Constraints::MAX_LENGTH_PAYMENT_ADDRESS;
|
||||
protected array $ffd_tags = [Ffd105Tags::COMPANY_PADDRESS];
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ declare(strict_types = 1);
|
||||
namespace AtolOnline\Exceptions;
|
||||
|
||||
use AtolOnline\Constants\Constraints;
|
||||
use AtolOnline\Constants\Ffd105Tags;
|
||||
|
||||
/**
|
||||
* Исключение, возникающее при попытке указать слишком длинную единицу измерения предмета расчёта
|
||||
@@ -19,6 +20,6 @@ use AtolOnline\Constants\Constraints;
|
||||
class TooLongUnitException extends TooLongException
|
||||
{
|
||||
protected $message = 'Слишком длинная единица измерения предмета расчёта';
|
||||
protected int $max = Constraints::MAX_LENGTH_MEASUREMENT_UNIT;
|
||||
protected array $ffd_tags = [1197];
|
||||
protected float $max = Constraints::MAX_LENGTH_MEASUREMENT_UNIT;
|
||||
protected array $ffd_tags = [Ffd105Tags::ITEM_MEASURE];
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ declare(strict_types = 1);
|
||||
namespace AtolOnline\Exceptions;
|
||||
|
||||
use AtolOnline\Constants\Constraints;
|
||||
use AtolOnline\Constants\Ffd105Tags;
|
||||
|
||||
/**
|
||||
* Исключение, возникающее при попытке указать слишком длинный дополнительный реквизит
|
||||
@@ -19,6 +20,6 @@ use AtolOnline\Constants\Constraints;
|
||||
class TooLongUserdataException extends TooLongException
|
||||
{
|
||||
protected $message = 'Слишком длинный дополнительный реквизит предмета расчёта';
|
||||
protected int $max = Constraints::MAX_LENGTH_USER_DATA;
|
||||
protected array $ffd_tags = [1191];
|
||||
protected float $max = Constraints::MAX_LENGTH_USER_DATA;
|
||||
protected array $ffd_tags = [Ffd105Tags::ITEM_USERDATA];
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ class TooManyException extends AtolException
|
||||
protected $message = 'Слишком большое количество';
|
||||
|
||||
/**
|
||||
* @var int Максимальное количество
|
||||
* @var float Максимальное количество
|
||||
*/
|
||||
protected int $max = 0;
|
||||
protected float $max = 0;
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
|
||||
@@ -19,5 +19,5 @@ use AtolOnline\Constants\Constraints;
|
||||
class TooManyItemsException extends TooManyException
|
||||
{
|
||||
protected $message = 'Слишком много предметов расчёта в документе';
|
||||
protected int $max = Constraints::MAX_COUNT_DOC_ITEMS;
|
||||
protected float $max = Constraints::MAX_COUNT_DOC_ITEMS;
|
||||
}
|
||||
|
||||
@@ -19,5 +19,5 @@ use AtolOnline\Constants\Constraints;
|
||||
class TooManyPaymentsException extends TooManyException
|
||||
{
|
||||
protected $message = 'Слишком много платежей в документе';
|
||||
protected int $max = Constraints::MAX_COUNT_DOC_PAYMENTS;
|
||||
protected float $max = Constraints::MAX_COUNT_DOC_PAYMENTS;
|
||||
}
|
||||
|
||||
@@ -19,5 +19,5 @@ use AtolOnline\Constants\Constraints;
|
||||
class TooManyVatsException extends TooManyException
|
||||
{
|
||||
protected $message = 'Слишком много ставок НДС в документе';
|
||||
protected int $max = Constraints::MAX_COUNT_DOC_VATS;
|
||||
protected float $max = Constraints::MAX_COUNT_DOC_VATS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user