From c7d07a18f10b017169668d4c3b3a3f27640edefb Mon Sep 17 00:00:00 2001 From: AnthonyAxenov Date: Sun, 12 Dec 2021 14:50:29 +0800 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=BE=D1=84=D0=B8?= =?UTF-8?q?=D0=BA=D1=81=D1=8B=20=D0=BF=D0=BE=20=D0=BA=D0=BE=D0=B4=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=B9=D0=BB=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Api/AtolClient.php | 34 ++++++++++------- src/Api/KktMonitor.php | 9 ++++- src/Api/KktResponse.php | 37 +++++++++++++------ src/Constants/Constraints.php | 29 ++++++++++++--- src/Entities/AdditionalUserProps.php | 9 ++++- src/Entities/Company.php | 10 ++++- src/Entities/Correction.php | 24 +++++++----- src/Entities/Entity.php | 4 +- src/Entities/Item.php | 4 +- src/Entities/Payment.php | 17 +++++++-- src/Entities/Receipt.php | 9 ++--- src/Entities/Vat.php | 20 +++++----- src/Enums/PaymentObjects.php | 1 + src/Enums/ReceiptOperationTypes.php | 2 +- src/Exceptions/AtolException.php | 2 + src/Exceptions/AuthFailedException.php | 2 + src/Exceptions/EmptyLoginException.php | 1 + src/Exceptions/EmptyPasswordException.php | 1 + .../InvalidPaymentAddressException.php | 4 +- src/Exceptions/InvalidUuidException.php | 12 +++--- src/TestEnvParams.php | 22 +++++++++++ 21 files changed, 178 insertions(+), 75 deletions(-) diff --git a/src/Api/AtolClient.php b/src/Api/AtolClient.php index ca3bf78..9b63445 100644 --- a/src/Api/AtolClient.php +++ b/src/Api/AtolClient.php @@ -11,15 +11,19 @@ declare(strict_types = 1); namespace AtolOnline\Api; -use AtolOnline\{ - Constants\Constraints, - Exceptions\AuthFailedException, - Exceptions\EmptyLoginException, - Exceptions\EmptyPasswordException, - Exceptions\TooLongLoginException, - Exceptions\TooLongPasswordException}; -use GuzzleHttp\Client; -use GuzzleHttp\Exception\GuzzleException; +use AtolOnline\Constants\Constraints; +use AtolOnline\Exceptions\{ + AuthFailedException, + EmptyLoginException, + EmptyPasswordException, + TooLongLoginException, + TooLongPasswordException +}; +use GuzzleHttp\{ + Client, + Exception\GuzzleException +}; +use JetBrains\PhpStorm\Pure; /** * Класс для подключения АТОЛ Онлайн API @@ -74,10 +78,13 @@ abstract class AtolClient ?string $login = null, ?string $password = null, array $config = [] - ) { - $this->http = new Client(array_merge($config, [ - 'http_errors' => $config['http_errors'] ?? false, - ])); + ) + { + $this->http = new Client( + array_merge($config, [ + 'http_errors' => $config['http_errors'] ?? false, + ]) + ); $this->setTestMode($test_mode); !is_null($login) && $this->setLogin($login); !is_null($password) && $this->setPassword($password); @@ -201,6 +208,7 @@ abstract class AtolClient * * @return array */ + #[Pure] private function getHeaders(): array { $headers['Content-type'] = 'application/json; charset=utf-8'; diff --git a/src/Api/KktMonitor.php b/src/Api/KktMonitor.php index e43f43c..a2989f0 100644 --- a/src/Api/KktMonitor.php +++ b/src/Api/KktMonitor.php @@ -12,10 +12,13 @@ declare(strict_types = 1); namespace AtolOnline\Api; use AtolOnline\Entities\Kkt; -use AtolOnline\Exceptions\EmptyMonitorDataException; -use AtolOnline\Exceptions\NotEnoughMonitorDataException; +use AtolOnline\Exceptions\{ + EmptyMonitorDataException, + NotEnoughMonitorDataException +}; use GuzzleHttp\Exception\GuzzleException; use Illuminate\Support\Collection; +use JetBrains\PhpStorm\Pure; /** * Класс для мониторинга ККТ @@ -27,6 +30,7 @@ class KktMonitor extends AtolClient /** * @inheritDoc */ + #[Pure] protected function getAuthEndpoint(): string { return $this->isTestMode() @@ -37,6 +41,7 @@ class KktMonitor extends AtolClient /** * @inheritDoc */ + #[Pure] protected function getMainEndpoint(): string { return $this->isTestMode() diff --git a/src/Api/KktResponse.php b/src/Api/KktResponse.php index 796df1a..78988af 100644 --- a/src/Api/KktResponse.php +++ b/src/Api/KktResponse.php @@ -7,13 +7,18 @@ * https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE */ +/** @noinspection PhpMultipleClassDeclarationsInspection */ + declare(strict_types = 1); namespace AtolOnline\Api; +use JetBrains\PhpStorm\{ + ArrayShape, + Pure +}; use JsonSerializable; use Psr\Http\Message\ResponseInterface; -use stdClass; use Stringable; /** @@ -30,10 +35,10 @@ class KktResponse implements JsonSerializable, Stringable protected int $code; /** - * @var stdClass|array|null Содержимое ответа сервера + * @var object|array|null Содержимое ответа сервера */ - protected stdClass|array|null $content; - + protected object|array|null $content; + /** * @var array Заголовки ответа */ @@ -50,7 +55,7 @@ class KktResponse implements JsonSerializable, Stringable $this->headers = $response->getHeaders(); $this->content = json_decode((string)$response->getBody()); } - + /** * Возвращает заголовки ответа * @@ -60,18 +65,19 @@ class KktResponse implements JsonSerializable, Stringable { return $this->headers; } - + /** * Возвращает запрошенный параметр из декодированного объекта результата * * @param $name * @return mixed */ + #[Pure] public function __get($name): mixed { return $this->getContent()?->$name; } - + /** * Возвращает код ответа * @@ -81,7 +87,7 @@ class KktResponse implements JsonSerializable, Stringable { return $this->code; } - + /** * Возвращает объект результата запроса * @@ -91,12 +97,13 @@ class KktResponse implements JsonSerializable, Stringable { return $this->content; } - + /** * Проверяет успешность запроса по соержимому результата * * @return bool */ + #[Pure] public function isValid(): bool { return !empty($this->getCode()) @@ -104,7 +111,7 @@ class KktResponse implements JsonSerializable, Stringable && empty($this->getContent()->error) && $this->getCode() < 400; } - + /** * Возвращает текстовое представление */ @@ -112,10 +119,16 @@ class KktResponse implements JsonSerializable, Stringable { return json_encode($this->jsonSerialize(), JSON_UNESCAPED_UNICODE); } - + /** * @inheritDoc */ + #[ArrayShape([ + 'code' => 'int', + 'headers' => 'array|\string[][]', + 'body' => 'mixed', + ] + )] public function jsonSerialize(): array { return [ @@ -124,4 +137,4 @@ class KktResponse implements JsonSerializable, Stringable 'body' => $this->content, ]; } -} \ No newline at end of file +} diff --git a/src/Constants/Constraints.php b/src/Constants/Constraints.php index ea2a905..6b03802 100644 --- a/src/Constants/Constraints.php +++ b/src/Constants/Constraints.php @@ -43,24 +43,28 @@ final class Constraints /** * Максимальная длина наименования покупателя (1227) + * * @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 17 */ const MAX_LENGTH_CLIENT_NAME = 256; /** * Максимальная длина наименования предмета расчёта (1030) + * * @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 21 */ const MAX_LENGTH_ITEM_NAME = 128; /** * Максимальная цена за единицу предмета расчёта (1079) + * * @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 21 */ const MAX_COUNT_ITEM_PRICE = 42949672.95; /** * Максимальное количество (вес) единицы предмета расчёта (1023) + * * @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 21 */ const MAX_COUNT_ITEM_QUANTITY = 99999.999; @@ -68,36 +72,42 @@ final class Constraints /** * Максимальная стоимость всех предметов расчёта в документе прихода, расхода, * возврата прихода, возврата расхода (1043) + * * @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 21 */ const MAX_COUNT_ITEM_SUM = 42949672.95; /** * Максимальная длина телефона или email покупателя (1008) + * * @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 17 */ const MAX_LENGTH_CLIENT_CONTACT = 64; /** * Длина операции для платёжного агента (1044) + * * @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 19 */ const MAX_LENGTH_PAYING_AGENT_OPERATION = 24; /** * Максимальное количество предметов расчёта в документе прихода, расхода, возврата прихода, возврата расхода + * * @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 21 */ const MAX_COUNT_DOC_ITEMS = 100; /** * Максимальная длина единицы измерения предмета расчётов + * * @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 21 */ const MAX_LENGTH_MEASUREMENT_UNIT = 16; /** * Максимальная длина пользовательских данных для предмета расчётов (1191) + * * @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 29 */ const MAX_LENGTH_USER_DATA = 64; @@ -118,12 +128,14 @@ final class Constraints /** * Максимальное количество платежей в любом документе + * * @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 30 и 35 */ const MAX_COUNT_DOC_PAYMENTS = 10; /** * Максимальное количество ставок НДС в любом документе + * * @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 31 и 36 */ const MAX_COUNT_DOC_VATS = 6; @@ -178,26 +190,31 @@ final class Constraints * * @see https://online.atol.ru/possystem/v4/schema/sell Схема "#/receipt/client/inn" */ - const PATTERN_INN = /* @lang PhpRegExp */ + const PATTERN_INN + = /* @lang PhpRegExp */ '/(^[\d]{10}$)|(^[\d]{12}$)/'; /** * Регулярное выражение для валидации номера телефона + * * @see https://online.atol.ru/possystem/v4/schema/sell Схема "#/definitions/phone_number" */ - const PATTERN_PHONE = /* @lang PhpRegExp */ + const PATTERN_PHONE + = /* @lang PhpRegExp */ '/^([^\s\\\]{0,17}|\+[^\s\\\]{1,18})$/'; /** * Регулярное выражение для валидации строки Callback URL */ - const PATTERN_CALLBACK_URL = /* @lang PhpRegExp */ - '/^http(s?)\:\/\/[0-9a-zA-Zа-яА-Я]' . - '([-.\w]*[0-9a-zA-Zа-яА-Я])*(:(0-9)*)*(\/?)([a-zAZ0-9а-яА-Я\-\.\?\,\'\/\\\+&=%\$#_]*)?$/'; + const PATTERN_CALLBACK_URL + = /* @lang PhpRegExp */ + '/^http(s?):\/\/[0-9a-zA-Zа-яА-Я]' . + '([-.\w]*[0-9a-zA-Zа-яА-Я])*(:(0-9)*)*(\/?)([a-zAZ0-9а-яА-Я\-.?,\'\/\\\+&=%\$#_]*)?$/'; /** * Регулярное выражение для валидации кода страны происхождения товара */ - const PATTERN_OKSM_CODE = /* @lang PhpRegExp */ + const PATTERN_OKSM_CODE + = /* @lang PhpRegExp */ '/^[\d]{3}$/'; } diff --git a/src/Entities/AdditionalUserProps.php b/src/Entities/AdditionalUserProps.php index bec5123..57e3aa0 100644 --- a/src/Entities/AdditionalUserProps.php +++ b/src/Entities/AdditionalUserProps.php @@ -16,8 +16,12 @@ use AtolOnline\Exceptions\{ EmptyAddUserPropNameException, EmptyAddUserPropValueException, TooLongAddUserPropNameException, - TooLongAddUserPropValueException}; -use JetBrains\PhpStorm\Pure; + TooLongAddUserPropValueException +}; +use JetBrains\PhpStorm\{ + ArrayShape, + Pure +}; /** * Класс, описывающий дополнительный реквизит пользователя @@ -117,6 +121,7 @@ final class AdditionalUserProps extends Entity * @inheritDoc */ #[Pure] + #[ArrayShape(['name' => 'string', 'value' => 'null|string'])] public function jsonSerialize(): array { return [ diff --git a/src/Entities/Company.php b/src/Entities/Company.php index ed665ca..e5b4b59 100644 --- a/src/Entities/Company.php +++ b/src/Entities/Company.php @@ -11,8 +11,14 @@ declare(strict_types = 1); namespace AtolOnline\Entities; -use AtolOnline\{Constants\Constraints, Enums\SnoTypes, Traits\HasEmail, Traits\HasInn}; -use AtolOnline\Exceptions\{InvalidEmailException, +use AtolOnline\{ + Constants\Constraints, + Enums\SnoTypes, + Traits\HasEmail, + Traits\HasInn +}; +use AtolOnline\Exceptions\{ + InvalidEmailException, InvalidEnumValueException, InvalidInnLengthException, InvalidPaymentAddressException, diff --git a/src/Entities/Correction.php b/src/Entities/Correction.php index 70a2193..2a8aea5 100644 --- a/src/Entities/Correction.php +++ b/src/Entities/Correction.php @@ -9,9 +9,15 @@ namespace AtolOnline\Entities; -use AtolOnline\Collections\{Payments, Vats}; -use AtolOnline\Constants\Constraints; -use AtolOnline\Exceptions\{InvalidEntityInCollectionException, TooLongCashierException}; +use AtolOnline\{ + Constants\Constraints, + Payments, + Vats +}; +use AtolOnline\Exceptions\{ + InvalidEntityInCollectionException, + TooLongCashierException +}; use Exception; use JetBrains\PhpStorm\ArrayShape; @@ -28,8 +34,8 @@ class Correction extends Entity protected Company $company; /** + * @todo вынести в трейт? * @var string|null ФИО кассира - * @todo вынести в трейт */ protected ?string $cashier = null; @@ -195,11 +201,11 @@ class Correction extends Entity * @throws InvalidEntityInCollectionException */ #[ArrayShape([ - 'company' => "\AtolOnline\Entities\Company", - 'correction_info' => "\AtolOnline\Entities\CorrectionInfo", - 'payments' => "array", - 'vats' => "\AtolOnline\Collections\Vats|null", - 'cashier' => "null|string" + 'company' => '\AtolOnline\Entities\Company', + 'correction_info' => '\AtolOnline\Entities\CorrectionInfo', + 'payments' => 'array', + 'vats' => '\AtolOnline\Collections\Vats|null', + 'cashier' => 'null|string', ])] public function jsonSerialize(): array { diff --git a/src/Entities/Entity.php b/src/Entities/Entity.php index 82eb1fc..24c524c 100644 --- a/src/Entities/Entity.php +++ b/src/Entities/Entity.php @@ -7,7 +7,9 @@ * https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE */ -declare(strict_types=1); +/** @noinspection PhpMultipleClassDeclarationsInspection */ + +declare(strict_types = 1); namespace AtolOnline\Entities; diff --git a/src/Entities/Item.php b/src/Entities/Item.php index e82bd7c..d994a02 100644 --- a/src/Entities/Item.php +++ b/src/Entities/Item.php @@ -556,8 +556,8 @@ final class Item extends Entity if (is_string($declaration_number)) { $declaration_number = trim($declaration_number); if ( - mb_strlen($declaration_number) < Constraints::MIN_LENGTH_DECLARATION_NUMBER || - mb_strlen($declaration_number) > Constraints::MAX_LENGTH_DECLARATION_NUMBER + mb_strlen($declaration_number) < Constraints::MIN_LENGTH_DECLARATION_NUMBER + || mb_strlen($declaration_number) > Constraints::MAX_LENGTH_DECLARATION_NUMBER ) { throw new InvalidDeclarationNumberException($declaration_number); } diff --git a/src/Entities/Payment.php b/src/Entities/Payment.php index f10d671..e4e57b4 100644 --- a/src/Entities/Payment.php +++ b/src/Entities/Payment.php @@ -11,10 +11,19 @@ declare(strict_types = 1); namespace AtolOnline\Entities; -use AtolOnline\Constants\Constraints; -use AtolOnline\Enums\PaymentTypes; -use AtolOnline\Exceptions\{InvalidEnumValueException, NegativePaymentSumException, TooHighPaymentSumException,}; -use JetBrains\PhpStorm\{ArrayShape, Pure}; +use AtolOnline\{ + Constants\Constraints, + Enums\PaymentTypes, +}; +use AtolOnline\Exceptions\{ + InvalidEnumValueException, + NegativePaymentSumException, + TooHighPaymentSumException, +}; +use JetBrains\PhpStorm\{ + ArrayShape, + Pure +}; /** * Класс, описывающий оплату diff --git a/src/Entities/Receipt.php b/src/Entities/Receipt.php index 07b40c5..ee5183b 100644 --- a/src/Entities/Receipt.php +++ b/src/Entities/Receipt.php @@ -34,8 +34,8 @@ final class Receipt extends Entity protected Client $client; /** + * @todo вынести в трейт? * @var Company Продавец - * @todo вынести в трейт */ protected Company $company; @@ -55,8 +55,8 @@ final class Receipt extends Entity protected Items $items; /** + * @todo вынести в трейт? * @var Payments Коллекция оплат - * @todo вынести в трейт */ protected Payments $payments; @@ -71,8 +71,8 @@ final class Receipt extends Entity protected float $total = 0; /** + * @todo вынести в трейт? * @var string|null ФИО кассира - * @todo вынести в трейт */ protected ?string $cashier = null; @@ -204,10 +204,9 @@ final class Receipt extends Entity * * @param Items $items * @return $this - * @throws EmptyItemsException * @throws InvalidEntityInCollectionException * @throws Exception - * @todo исключение при пустой коллекции + * @throws EmptyItemsException */ public function setItems(Items $items): self { diff --git a/src/Entities/Vat.php b/src/Entities/Vat.php index 5b16069..e65e829 100644 --- a/src/Entities/Vat.php +++ b/src/Entities/Vat.php @@ -106,15 +106,17 @@ final class Vat extends Entity #[Pure] public function getCalculated(): float { - return Helpers::toRub(match ($this->getType()) { - VatTypes::VAT10 => Helpers::toKop($this->sum) * 10 / 100, - VatTypes::VAT18 => Helpers::toKop($this->sum) * 18 / 100, - VatTypes::VAT20 => Helpers::toKop($this->sum) * 20 / 100, - VatTypes::VAT110 => Helpers::toKop($this->sum) * 10 / 110, - VatTypes::VAT118 => Helpers::toKop($this->sum) * 18 / 118, - VatTypes::VAT120 => Helpers::toKop($this->sum) * 20 / 120, - default => 0, - }); + return Helpers::toRub( + match ($this->getType()) { + VatTypes::VAT10 => Helpers::toKop($this->sum) * 10 / 100, + VatTypes::VAT18 => Helpers::toKop($this->sum) * 18 / 100, + VatTypes::VAT20 => Helpers::toKop($this->sum) * 20 / 100, + VatTypes::VAT110 => Helpers::toKop($this->sum) * 10 / 110, + VatTypes::VAT118 => Helpers::toKop($this->sum) * 18 / 118, + VatTypes::VAT120 => Helpers::toKop($this->sum) * 20 / 120, + default => 0, + } + ); } /** diff --git a/src/Enums/PaymentObjects.php b/src/Enums/PaymentObjects.php index eee6f8c..c5ac2f0 100644 --- a/src/Enums/PaymentObjects.php +++ b/src/Enums/PaymentObjects.php @@ -77,6 +77,7 @@ final class PaymentObjects extends Enum /** * Составной предмет расчёта + * * @deprecated Более не используется согласно ФФД 1.05 * @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 25 (payment_object) */ diff --git a/src/Enums/ReceiptOperationTypes.php b/src/Enums/ReceiptOperationTypes.php index 2e55820..ad342c5 100644 --- a/src/Enums/ReceiptOperationTypes.php +++ b/src/Enums/ReceiptOperationTypes.php @@ -47,4 +47,4 @@ final class ReceiptOperationTypes extends Enum * Коррекция прихода (догоняем неучтённые средства) */ const BUY_CORRECTION = 'buy_correction'; -} \ No newline at end of file +} diff --git a/src/Exceptions/AtolException.php b/src/Exceptions/AtolException.php index 6a7f34e..199cb5d 100644 --- a/src/Exceptions/AtolException.php +++ b/src/Exceptions/AtolException.php @@ -12,6 +12,7 @@ declare(strict_types = 1); namespace AtolOnline\Exceptions; use Exception; +use JetBrains\PhpStorm\Pure; /** * Исключение, возникающее при работе с АТОЛ Онлайн @@ -29,6 +30,7 @@ class AtolException extends Exception * @param string $message Сообщение * @param int[] $ffd_tags Переопредление тегов ФФД */ + #[Pure] public function __construct(string $message = '', array $ffd_tags = []) { $tags = implode(', ', $ffd_tags ?: $this->ffd_tags); diff --git a/src/Exceptions/AuthFailedException.php b/src/Exceptions/AuthFailedException.php index 0d379b0..61be470 100644 --- a/src/Exceptions/AuthFailedException.php +++ b/src/Exceptions/AuthFailedException.php @@ -13,6 +13,7 @@ namespace AtolOnline\Exceptions; use AtolOnline\Api\KktResponse; use Exception; +use JetBrains\PhpStorm\Pure; /** * Исключение, возникающее при неудачной авторизации @@ -25,6 +26,7 @@ class AuthFailedException extends Exception * @param KktResponse $response * @param string $message */ + #[Pure] public function __construct(KktResponse $response, string $message = '') { parent::__construct(($message ?: 'Ошибка авторизации: ') . ': ' . $response); diff --git a/src/Exceptions/EmptyLoginException.php b/src/Exceptions/EmptyLoginException.php index 5e78966..49e4ff9 100644 --- a/src/Exceptions/EmptyLoginException.php +++ b/src/Exceptions/EmptyLoginException.php @@ -13,6 +13,7 @@ namespace AtolOnline\Exceptions; /** * Исключение, возникающее при попытке указать пустой логин + * * @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 12 */ class EmptyLoginException extends AtolException diff --git a/src/Exceptions/EmptyPasswordException.php b/src/Exceptions/EmptyPasswordException.php index 76f4a9d..e533229 100644 --- a/src/Exceptions/EmptyPasswordException.php +++ b/src/Exceptions/EmptyPasswordException.php @@ -13,6 +13,7 @@ namespace AtolOnline\Exceptions; /** * Исключение, возникающее при попытке указать пустой пароль + * * @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 12 */ class EmptyPasswordException extends AtolException diff --git a/src/Exceptions/InvalidPaymentAddressException.php b/src/Exceptions/InvalidPaymentAddressException.php index 59a0bef..7fb8af0 100644 --- a/src/Exceptions/InvalidPaymentAddressException.php +++ b/src/Exceptions/InvalidPaymentAddressException.php @@ -12,6 +12,7 @@ declare(strict_types = 1); namespace AtolOnline\Exceptions; use AtolOnline\Constants\Ffd105Tags; +use JetBrains\PhpStorm\Pure; /** * Исключение, возникающее при попытке указать некорректный адрес места расчётов @@ -28,7 +29,8 @@ class InvalidPaymentAddressException extends AtolException * @param string $address * @param string $message */ - public function __construct($address = '', $message = "") + #[Pure] + public function __construct(string $address = '', string $message = '') { parent::__construct($message ?: "Некорректный адрес места расчётов: '$address'"); } diff --git a/src/Exceptions/InvalidUuidException.php b/src/Exceptions/InvalidUuidException.php index e96ed82..77fcba6 100644 --- a/src/Exceptions/InvalidUuidException.php +++ b/src/Exceptions/InvalidUuidException.php @@ -11,6 +11,8 @@ declare(strict_types = 1); namespace AtolOnline\Exceptions; +use JetBrains\PhpStorm\Pure; + /** * Исключение, возникающее при ошибке валидации UUID */ @@ -19,13 +21,11 @@ class InvalidUuidException extends AtolException /** * Конструктор * - * @param $uuid - * @param string $message - * @param int $code - * @param Throwable|null $previous + * @param string $uuid */ - public function __construct(?string $uuid = null) + #[Pure] + public function __construct(string $uuid = '') { - parent::__construct('Невалидный UUID' . ($uuid ? ': ' . $uuid : '')); + parent::__construct('Невалидный UUID: ' . $uuid); } } diff --git a/src/TestEnvParams.php b/src/TestEnvParams.php index 46e7733..c1745cd 100644 --- a/src/TestEnvParams.php +++ b/src/TestEnvParams.php @@ -11,6 +11,8 @@ declare(strict_types = 1); namespace AtolOnline; +use JetBrains\PhpStorm\ArrayShape; + /** * Константы, определяющие параметры тестовых сред * @@ -23,6 +25,16 @@ final class TestEnvParams * * @return string[] */ + #[ArrayShape([ + 'endpoint' => "string", + 'company_name' => "string", + 'inn' => "string", + 'payment_address' => "string", + 'group' => "string", + 'login' => "string", + 'password' => "string", + 'endpoint_ofd' => "string", + ])] public static function FFD105(): array { return [ @@ -43,6 +55,16 @@ final class TestEnvParams * @return string[] * @noinspection PhpUnused */ + #[ArrayShape([ + 'endpoint' => "string", + 'company_name' => "string", + 'inn' => "string", + 'payment_address' => "string", + 'group' => "string", + 'login' => "string", + 'password' => "string", + 'endpoint_ofd' => "string", + ])] public static function FFD12(): array { return [