Мелкофиксы по кодстайлу
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user