From fa80e90979372fb3b2f393133ee0e6019b772aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kr=C3=A1l?= Date: Mon, 11 May 2020 22:42:38 +0200 Subject: [PATCH 1/7] PHP 7.4 updates This reverts commit 17cffe15a8707d0cd731bdadb3440009c28fe62d. --- .travis.yml | 2 +- composer.json | 5 +- ruleset.xml | 187 +++++++++++++++++++++--- src/Client.php | 192 ++++++++----------------- src/CompanyClient.php | 13 +- src/Config.php | 47 ++---- src/Enum/SearchQueryOperator.php | 2 +- src/Http/HttpClient.php | 65 +++++++++ src/Http/HttpCurlBuilder.php | 57 ++++++++ src/Http/Response/FlexibeeResponse.php | 34 ++--- src/Http/ResponseFactory.php | 36 ++++- src/Http/ResponseHydrator.php | 5 +- src/Http/UrlBuilder.php | 15 +- src/Http/UrlNormalizer.php | 13 ++ src/Result/EvidenceResult.php | 2 +- 15 files changed, 433 insertions(+), 242 deletions(-) create mode 100644 src/Http/HttpClient.php create mode 100644 src/Http/HttpCurlBuilder.php create mode 100644 src/Http/UrlNormalizer.php diff --git a/.travis.yml b/.travis.yml index 28c83df..3066db8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: php php: - - 7.3 + - 7.4 before_script: - composer self-update diff --git a/composer.json b/composer.json index 5ae069d..3d2ad8e 100644 --- a/composer.json +++ b/composer.json @@ -7,13 +7,14 @@ "require": { "ext-simplexml": "*", "ext-curl": "*", + "ext-mbstring": "*", "ext-json": "*", "ext-mbstring": "*", - "php": "^7.3", + "php": "^7.4", "jwage/purl": "^1.0", "rakit/validation": "^1.1", "consistence/consistence": "^2.0" - }, + }, "require-dev": { "slevomat/coding-standard": "^6.0", "phpunit/phpunit": "^9.0", diff --git a/ruleset.xml b/ruleset.xml index 1eb5d93..ed03d30 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -1,27 +1,168 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Client.php b/src/Client.php index e9e7db3..f5d0ee8 100644 --- a/src/Client.php +++ b/src/Client.php @@ -2,15 +2,12 @@ namespace EcomailFlexibee; -use EcomailFlexibee\Exception\EcomailFlexibeeConnectionError; use EcomailFlexibee\Exception\EcomailFlexibeeNoEvidenceResult; use EcomailFlexibee\Exception\EcomailFlexibeeSaveFailed; +use EcomailFlexibee\Http\HttpClient; use EcomailFlexibee\Http\Method; -use EcomailFlexibee\Http\Response\FlexibeeBackupResponse; -use EcomailFlexibee\Http\Response\FlexibeePdfResponse; use EcomailFlexibee\Http\Response\FlexibeeResponse; use EcomailFlexibee\Http\Response\Response; -use EcomailFlexibee\Http\ResponseFactory; use EcomailFlexibee\Http\ResponseHydrator; use EcomailFlexibee\Http\UrlBuilder; use EcomailFlexibee\Result\EvidenceResult; @@ -18,20 +15,11 @@ class Client { - /** - * @var \EcomailFlexibee\Http\UrlBuilder - */ - protected $queryBuilder; + protected \EcomailFlexibee\Http\UrlBuilder $queryBuilder; + protected \EcomailFlexibee\Http\HttpClient $httpClient; + protected \EcomailFlexibee\Config $config; - /** - * @var \EcomailFlexibee\Config - */ - private $config; - - /** - * @var \EcomailFlexibee\Http\ResponseHydrator - */ - private $responseHydrator; + private \EcomailFlexibee\Http\ResponseHydrator $responseHydrator; public function __construct( string $url, @@ -54,49 +42,54 @@ public function __construct( ); $this->queryBuilder = new UrlBuilder($this->config); $this->responseHydrator = new ResponseHydrator($this->config); + $this->httpClient = new HttpClient(); } public function isAllowedChangesApi(): bool { - return $this->makeRequest( - Method::get(Method::GET), + return $this->httpClient->request( $this->queryBuilder->createChangesStatusUrl(), + Method::get(Method::GET), [], [], [], + $this->config, )->isSuccess(); } public function getChangesApiForEvidence(string $evidenceName): Response { - return $this->makeRequest( - Method::get(Method::GET), + return $this->httpClient->request( $this->queryBuilder->createChangesUrl(['evidence' => $evidenceName]), + Method::get(Method::GET), [], [], [], + $this->config, ); } public function getPropertiesForEvidence(): Response { - return $this->makeRequest( - Method::get(Method::GET), + return $this->httpClient->request( $this->queryBuilder->createUri('properties', []), + Method::get(Method::GET), [], [], [], + $this->config, ); } public function getAllApiChanges(?string $fromVersion): Response { - return $this->makeRequest( - Method::get(Method::GET), + return $this->httpClient->request( $this->queryBuilder->createChangesUrl(['start' => $fromVersion]), + Method::get(Method::GET), [], [], [], + $this->config, ); } @@ -111,17 +104,18 @@ public function getLoginFormUrl(array $parameters): string public function getAuthAndRefreshToken(): Response { - return $this->makeRequest( - Method::get(Method::POST), + return $this->httpClient->request( $this->queryBuilder->createAuthTokenUrl(), + Method::get(Method::POST), [], - [ - 'Content-Type: application/x-www-form-urlencoded', - ], [ 'username' => $this->config->getUser(), 'password' => $this->config->getPassword(), ], + [ + 'Content-Type: application/x-www-form-urlencoded', + ], + $this->config, ); } @@ -129,22 +123,26 @@ public function deleteById(int $id, bool $dryRun = false): Response { $uriParameters = $dryRun ? ['dry-run' => 'true'] : []; - return $this->makeRequest( - Method::get(Method::DELETE), + return $this->httpClient->request( $this->queryBuilder->createUri($id, $uriParameters), + Method::get(Method::DELETE), [], + [], + [], + $this->config, ); } public function deleteByCode(string $id, bool $dryRun = false): void { $uriParameters = $dryRun ? ['dry-run' => 'true'] : []; - $this->makeRequest( - Method::get(Method::DELETE), + $this->httpClient->request( $this->queryBuilder->createUri(\sprintf('code:%s', $id), $uriParameters), + Method::get(Method::DELETE), [], [], [], + $this->config, ); } @@ -184,10 +182,13 @@ public function findById(int $id, array $uriParameters = []): EvidenceResult public function getByCode(string $code, array $uriParameters = []): EvidenceResult { return $this->responseHydrator->convertResponseToEvidenceResult( - $this->makeRequest( - Method::get(Method::GET), + $this->httpClient->request( $this->queryBuilder->createUriByCodeOnly($code, $uriParameters), + Method::get(Method::GET), + [], + [], [], + $this->config, ) , true, ); @@ -208,10 +209,13 @@ public function getByCode(string $code, array $uriParameters = []): EvidenceResu public function getById(int $id, array $uriParameters = []): EvidenceResult { return $this->responseHydrator->convertResponseToEvidenceResult( - $this->makeRequest( - Method::get(Method::GET), + $this->httpClient->request( $this->queryBuilder->createUri($id, $uriParameters), + Method::get(Method::GET), + [], [], + [], + $this->config, ), true, ); @@ -326,12 +330,13 @@ public function addUserRelation(int $objectAId, int $objectBId, float $price, in */ public function allInEvidence(): array { - $response = $this->makeRequest( - Method::get(Method::GET), + $response = $this->httpClient->request( $this->queryBuilder->createUriByEvidenceOnly(['limit' => 0]), + Method::get(Method::GET), [], [], [], + $this->config, ); return $this->responseHydrator->convertResponseToEvidenceResults($response); @@ -339,12 +344,13 @@ public function allInEvidence(): array public function countInEvidence(): int { - $response = $this->makeRequest( - Method::get(Method::GET), + $response = $this->httpClient->request( $this->queryBuilder->createUriByEvidenceOnly(['add-row-count' => 'true']), + Method::get(Method::GET), [], [], [], + $this->config, ); return $response->getRowCount() ?? 0; @@ -363,12 +369,13 @@ public function countInEvidence(): int */ public function chunkInEvidence(int $start, int $limit): array { - $response = $this->makeRequest( - Method::get(Method::GET), + $response = $this->httpClient->request( $this->queryBuilder->createUriByEvidenceOnly(['limit' => $limit, 'start' => $start]), + Method::get(Method::GET), [], [], [], + $this->config, ); return $this->responseHydrator->convertResponseToEvidenceResults($response); @@ -387,12 +394,13 @@ public function chunkInEvidence(int $start, int $limit): array */ public function searchInEvidence(string $query, array $uriParameters): array { - $response = $this->makeRequest( - Method::get(Method::GET), + $response = $this->httpClient->request( $this->queryBuilder->createFilterQuery($query, $uriParameters), + Method::get(Method::GET), [], [], [], + $this->config, ); return $this->responseHydrator->convertResponseToEvidenceResults($response); @@ -420,11 +428,13 @@ public function callRequest( array $headers ): array { - $response = $this->makeRequest( - $httpMethod, + $response = $this->httpClient->request( $this->queryBuilder->createUri($queryFilterOrId, $uriParameters), + $httpMethod, $postFields, + [], $headers, + $this->config, ); return $this->responseHydrator->convertResponseToEvidenceResults($response); @@ -443,90 +453,14 @@ public function callRequest( */ public function getPdfById(int $id, array $uriParameters): Response { - return $this->makeRequest( - Method::get(Method::GET), + return $this->httpClient->request( $this->queryBuilder->createPdfUrl($id, $uriParameters), + Method::get(Method::GET), + [], + [], [], + $this->config, ); } - /** - * @param \EcomailFlexibee\Http\Method $httpMethod - * @param string $url - * @param array $postFields - * @param array $headers - * @param array $queryParameters - * @param bool $rawPostFields - * @return \EcomailFlexibee\Http\Response\Response|\EcomailFlexibee\Http\Response\FlexibeePdfResponse - * @throws \EcomailFlexibee\Exception\EcomailFlexibeeConnectionError - * @throws \EcomailFlexibee\Exception\EcomailFlexibeeForbidden - * @throws \EcomailFlexibee\Exception\EcomailFlexibeeInvalidAuthorization - * @throws \EcomailFlexibee\Exception\EcomailFlexibeeMethodNotAllowed - * @throws \EcomailFlexibee\Exception\EcomailFlexibeeNotAcceptableRequest - * @throws \EcomailFlexibee\Exception\EcomailFlexibeeRequestError - */ - protected function makeRequest(Method $httpMethod, string $url, array $postFields = [], array $headers = [], array $queryParameters = [], bool $rawPostFields = false) - { - $url = \urldecode($url); - - /** @var resource $ch */ - $ch = \curl_init(); - \curl_setopt($ch, \CURLOPT_FOLLOWLOCATION, TRUE); - \curl_setopt($ch, \CURLOPT_RETURNTRANSFER, TRUE); - - if ($this->config->getAuthSessionId() !== null) { - \curl_setopt($ch, \CURLOPT_HTTPAUTH, FALSE); - $headers[] = \sprintf('X-authSessionId: %s', $this->config->getAuthSessionId()); - } else { - \curl_setopt($ch, \CURLOPT_HTTPAUTH, TRUE); - \curl_setopt($ch, \CURLOPT_USERPWD, \sprintf('%s:%s', $this->config->getUser(), $this->config->getPassword())); - } - - \curl_setopt($ch, \CURLOPT_URL, $url); - \curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, $httpMethod->getValue()); - \curl_setopt($ch, \CURLOPT_USERAGENT, 'Ecomail.cz Flexibee client (https://github.com/Ecomailcz/flexibee-client)'); - - if ($this->config->isSelfSignedCertificate() || $this->config->getAuthSessionId() !== null) { - \curl_setopt($ch, \CURLOPT_SSL_VERIFYPEER, FALSE); - \curl_setopt($ch, \CURLOPT_SSL_VERIFYHOST, FALSE); - } - - $postData = []; - - if (\count($postFields) !== 0) { - if (!$rawPostFields) { - $postData['winstrom'] = $postFields; - \curl_setopt($ch, \CURLOPT_POSTFIELDS, \json_encode($postData)); - } else { - \curl_setopt($ch, \CURLOPT_POSTFIELDS, \implode("\n", $postFields)); - } - } - - if (\count($queryParameters) !== 0) { - \curl_setopt($ch, \CURLOPT_POSTFIELDS, \http_build_query($queryParameters)); - } - - if (\count($headers) !== 0) { - \curl_setopt($ch, \CURLOPT_HTTPHEADER, $headers); - } - - $output = \curl_exec($ch); - - if (\curl_errno($ch) !== \CURLE_OK || !\is_string($output)) { - throw new EcomailFlexibeeConnectionError(\sprintf('cURL error (%s): %s', \curl_errno($ch), \curl_error($ch))); - } - - // PDF content - if (\mb_strpos($url, '.pdf') !== false) { - return new FlexibeePdfResponse($output); - } - - // Backup content - if ($httpMethod->equalsValue(Method::GET) && \mb_stripos($url, '/backup') !== false) { - return new FlexibeeBackupResponse($output); - } - - return ResponseFactory::createFromOutput($output, \curl_getinfo($ch, \CURLINFO_HTTP_CODE)); - } - } diff --git a/src/CompanyClient.php b/src/CompanyClient.php index a93f591..9c4a704 100644 --- a/src/CompanyClient.php +++ b/src/CompanyClient.php @@ -25,22 +25,25 @@ public function __construct(Config $config) public function backup(): Response { - return $this->makeRequest( - Method::get(Method::GET), + return $this->httpClient->request( $this->queryBuilder->createBackupUrl(), + Method::get(Method::GET), + [], [], + [], + $this->config, ); } public function restore(string $companyName, string $data): Response { - return $this->makeRequest( - Method::get(Method::PUT), + return $this->httpClient->request( $this->queryBuilder->createRestoreUrl($companyName), + Method::get(Method::PUT), [$data], [], [], - true, + $this->config, ); } diff --git a/src/Config.php b/src/Config.php index d6a73d0..b9ba275 100644 --- a/src/Config.php +++ b/src/Config.php @@ -5,40 +5,19 @@ final class Config { - /** - * @var string - */ - private $url; - - /** - * @var string - */ - private $company; - - /** - * @var string - */ - private $user; - - /** - * @var string - */ - private $password; - - /** - * @var string - */ - private $evidence; - - /** - * @var bool - */ - private $selfSignedCertificate; - - /** - * @var string|null - */ - private $authSessionId; + private string $url; + + private string $company; + + private string $user; + + private string $password; + + private string $evidence; + + private bool $selfSignedCertificate; + + private ?string $authSessionId = null; public function __construct( string $url, diff --git a/src/Enum/SearchQueryOperator.php b/src/Enum/SearchQueryOperator.php index f9cd90a..52d12ce 100644 --- a/src/Enum/SearchQueryOperator.php +++ b/src/Enum/SearchQueryOperator.php @@ -10,7 +10,7 @@ class SearchQueryOperator extends Enum /** * @var array */ - private static $operators = [ + private static array $operators = [ '==' => ' eq ', '<=' => ' lte ', '<>' => ' neq ', diff --git a/src/Http/HttpClient.php b/src/Http/HttpClient.php new file mode 100644 index 0000000..5db67e9 --- /dev/null +++ b/src/Http/HttpClient.php @@ -0,0 +1,65 @@ +urlNormalizer = new UrlNormalizer(); + $this->httpCurlBuilder = new HttpCurlBuilder(); + } + + /** + * @param array $postFields + * @param array $queryParameters + * @param array $headers + * @throws \EcomailFlexibee\Exception\EcomailFlexibeeConnectionError + * @throws \EcomailFlexibee\Exception\EcomailFlexibeeForbidden + * @throws \EcomailFlexibee\Exception\EcomailFlexibeeInvalidAuthorization + * @throws \EcomailFlexibee\Exception\EcomailFlexibeeMethodNotAllowed + * @throws \EcomailFlexibee\Exception\EcomailFlexibeeNotAcceptableRequest + * @throws \EcomailFlexibee\Exception\EcomailFlexibeeRequestError + */ + public function request( + string $url, + Method $httpMethod, + array $postFields, + array $queryParameters, + array $headers, + Config $config + ): \EcomailFlexibee\Http\Response\FlexibeeResponse + { + + $ch = $this->httpCurlBuilder->build( + $this->urlNormalizer->normalize($url), + $httpMethod, + $postFields, + $queryParameters, + $headers, + $config, + ); + + $output = \curl_exec($ch); + $output = \is_string($output) ? $output : null; + $errorMessage = \mb_strlen(\trim(\curl_error($ch))) + ? null + : \curl_error($ch); + + return ResponseFactory::createFromOutput( + $url, + $httpMethod, + $output, + \curl_getinfo($ch, \CURLINFO_HTTP_CODE), + \curl_errno($ch), + $errorMessage, + ); + } + +} diff --git a/src/Http/HttpCurlBuilder.php b/src/Http/HttpCurlBuilder.php new file mode 100644 index 0000000..6dcea0b --- /dev/null +++ b/src/Http/HttpCurlBuilder.php @@ -0,0 +1,57 @@ + $postFields + * @param array $queryParameters + * @param array $headers + * @return resource + */ + public function build(string $url, Method $httpMethod, array $postFields, array $queryParameters, array $headers, Config $config) + { + /** @var resource $ch */ + $ch = \curl_init(); + \curl_setopt($ch, \CURLOPT_FOLLOWLOCATION, TRUE); + \curl_setopt($ch, \CURLOPT_RETURNTRANSFER, TRUE); + + if ($config->getAuthSessionId() !== null) { + \curl_setopt($ch, \CURLOPT_HTTPAUTH, FALSE); + $headers[] = \sprintf('X-authSessionId: %s', $config->getAuthSessionId()); + } else { + \curl_setopt($ch, \CURLOPT_HTTPAUTH, TRUE); + \curl_setopt($ch, \CURLOPT_USERPWD, \sprintf('%s:%s', $config->getUser(), $config->getPassword())); + } + + \curl_setopt($ch, \CURLOPT_URL, $url); + \curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, $httpMethod->getValue()); + \curl_setopt($ch, \CURLOPT_USERAGENT, 'Ecomail.cz Flexibee client (https://github.com/Ecomailcz/flexibee-client)'); + + if ($config->isSelfSignedCertificate() || $config->getAuthSessionId() !== null) { + \curl_setopt($ch, \CURLOPT_SSL_VERIFYPEER, FALSE); + \curl_setopt($ch, \CURLOPT_SSL_VERIFYHOST, FALSE); + } + + if (\count($postFields) > 0) { + \curl_setopt($ch, \CURLOPT_POSTFIELDS, \json_encode([ + 'winstrom' => $postFields, + ])); + } + + if (\count($queryParameters) > 0) { + \curl_setopt($ch, \CURLOPT_POSTFIELDS, \http_build_query($queryParameters)); + } + + if (\count($headers) !== 0) { + \curl_setopt($ch, \CURLOPT_HTTPHEADER, $headers); + } + + return $ch; + } + +} diff --git a/src/Http/Response/FlexibeeResponse.php b/src/Http/Response/FlexibeeResponse.php index c6a27d2..d11042d 100644 --- a/src/Http/Response/FlexibeeResponse.php +++ b/src/Http/Response/FlexibeeResponse.php @@ -5,45 +5,27 @@ class FlexibeeResponse implements Response { - /** - * @var float|null - */ - private $version; + private ?float $version = null; - /** - * @var bool - */ - private $success; + private bool $success; - /** - * @var string|null - */ - private $message; + private ?string $message = null; - /** - * @var int - */ - private $statusCode; + private int $statusCode; /** * @var array */ - private $data; + private array $data; /** * @var array */ - private $statistics = []; + private array $statistics = []; - /** - * @var int - */ - private $rowCount = 0; + private int $rowCount = 0; - /** - * @var int|null - */ - private $globalVersion; + private ?int $globalVersion = null; /** * FlexibeeResponse constructor. diff --git a/src/Http/ResponseFactory.php b/src/Http/ResponseFactory.php index 12c76fc..2c866ae 100644 --- a/src/Http/ResponseFactory.php +++ b/src/Http/ResponseFactory.php @@ -2,27 +2,55 @@ namespace EcomailFlexibee\Http; +use EcomailFlexibee\Exception\EcomailFlexibeeConnectionError; use EcomailFlexibee\Exception\EcomailFlexibeeForbidden; use EcomailFlexibee\Exception\EcomailFlexibeeInvalidAuthorization; use EcomailFlexibee\Exception\EcomailFlexibeeMethodNotAllowed; use EcomailFlexibee\Exception\EcomailFlexibeeNotAcceptableRequest; use EcomailFlexibee\Exception\EcomailFlexibeeRequestError; +use EcomailFlexibee\Http\Response\FlexibeeBackupResponse; +use EcomailFlexibee\Http\Response\FlexibeePdfResponse; use EcomailFlexibee\Http\Response\FlexibeeResponse; final class ResponseFactory { - public static function createFromOutput(string $response, int $statusCode): FlexibeeResponse + public static function createFromOutput( + string $url, + Method $httpMethod, + ?string $responseContent, + int $statusCode, + int $errorNumber, + ?string $errorMessage + ): FlexibeeResponse { + if ($responseContent === null) { + throw new EcomailFlexibeeRequestError(); + } + + if ($errorNumber !== \CURLE_OK && $errorMessage !== null) { + throw new EcomailFlexibeeConnectionError(\sprintf('cURL error (%s): %s', $errorNumber, $errorMessage)); + } + + // PDF content + if (\mb_strpos($url, '.pdf') !== false) { + return new FlexibeePdfResponse($responseContent); + } + + // Backup content + if ($httpMethod->equalsValue(Method::GET) && \mb_stripos($url, '/backup') !== false) { + return new FlexibeeBackupResponse($responseContent); + } + /** @var array|null $data */ - $data = \json_decode($response, true); - $data = $data ?? []; + $data = \json_decode($responseContent, true); + $data ??= []; $data = $data['winstrom'] ?? $data; $results = $data['results'] ?? $data; $version = null; /** @var string|null $message */ - $message = $response; + $message = $responseContent; $success = false; $statistics = []; $rowCount = 0; diff --git a/src/Http/ResponseHydrator.php b/src/Http/ResponseHydrator.php index 750eebe..04d7d9c 100644 --- a/src/Http/ResponseHydrator.php +++ b/src/Http/ResponseHydrator.php @@ -12,10 +12,7 @@ class ResponseHydrator extends ObjectPrototype { - /** - * @var \EcomailFlexibee\Config - */ - private $config; + private \EcomailFlexibee\Config $config; public function __construct(Config $config) { diff --git a/src/Http/UrlBuilder.php b/src/Http/UrlBuilder.php index 9e0839f..177d74a 100644 --- a/src/Http/UrlBuilder.php +++ b/src/Http/UrlBuilder.php @@ -13,20 +13,11 @@ class UrlBuilder extends Url { - /** - * @var string - */ - private $company; + private string $company; - /** - * @var string - */ - private $evidence; + private string $evidence; - /** - * @var \EcomailFlexibee\Validator\ParameterValidator - */ - private $validator; + private \EcomailFlexibee\Validator\ParameterValidator $validator; public function __construct(Config $config, ?ParserInterface $parser = null) { diff --git a/src/Http/UrlNormalizer.php b/src/Http/UrlNormalizer.php new file mode 100644 index 0000000..6d2a4bf --- /dev/null +++ b/src/Http/UrlNormalizer.php @@ -0,0 +1,13 @@ + */ - private $data; + private array $data; /** * @param array $data From cf1f68351437f81c5774e4ba175f84214bb7d635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kr=C3=A1l?= Date: Wed, 20 May 2020 18:55:38 +0200 Subject: [PATCH 2/7] Composer - update dependencies --- composer.json | 6 ++++-- composer.lock | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 3d2ad8e..06fd668 100644 --- a/composer.json +++ b/composer.json @@ -1,13 +1,12 @@ { "name": "ecomailcz/flexibee-client", - "description": "Basic client for make FlexiBee requests", + "description": "ECOMAIL.CZ - Simple client for communication with FlexiBee API", "license": ["MIT"], "minimum-stability": "dev", "prefer-stable": true, "require": { "ext-simplexml": "*", "ext-curl": "*", - "ext-mbstring": "*", "ext-json": "*", "ext-mbstring": "*", "php": "^7.4", @@ -33,5 +32,8 @@ }, "autoload-dev": { "classmap": ["tests/"] + }, + "config": { + "sort-packages": true } } diff --git a/composer.lock b/composer.lock index 4e91014..bdb60a5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cf46e601dea5414ced8ffdf82eb0a0d0", + "content-hash": "3637ac05c3ccca5cce944e4e7454c335", "packages": [ { "name": "consistence/consistence", @@ -2348,9 +2348,9 @@ "platform": { "ext-simplexml": "*", "ext-curl": "*", - "ext-json": "*", "ext-mbstring": "*", - "php": "^7.3" + "ext-json": "*", + "php": "^7.4" }, "platform-dev": [] } From 5a16169f5592fb87d368b10d5736a9813a4b834e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kr=C3=A1l?= Date: Wed, 20 May 2020 19:10:25 +0200 Subject: [PATCH 3/7] PHPStan - fixies --- build.xml | 7 + composer.json | 49 ++- composer.lock | 508 +++++++++++++++++++++++++- src/Http/HttpClient.php | 2 +- src/RecurringContractClient.php | 34 -- tests/RecurringContractClientTest.php | 38 -- 6 files changed, 543 insertions(+), 95 deletions(-) delete mode 100644 src/RecurringContractClient.php delete mode 100644 tests/RecurringContractClientTest.php diff --git a/build.xml b/build.xml index 0c67061..abd5693 100644 --- a/build.xml +++ b/build.xml @@ -8,6 +8,13 @@ + + + + + + + diff --git a/composer.json b/composer.json index 06fd668..df24182 100644 --- a/composer.json +++ b/composer.json @@ -1,39 +1,52 @@ { "name": "ecomailcz/flexibee-client", "description": "ECOMAIL.CZ - Simple client for communication with FlexiBee API", - "license": ["MIT"], - "minimum-stability": "dev", - "prefer-stable": true, + "license": [ + "MIT" + ], "require": { - "ext-simplexml": "*", + "php": "^7.4", "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", - "php": "^7.4", + "ext-simplexml": "*", + "consistence/consistence": "^2.0", "jwage/purl": "^1.0", - "rakit/validation": "^1.1", - "consistence/consistence": "^2.0" - }, + "rakit/validation": "^1.1" + }, "require-dev": { - "slevomat/coding-standard": "^6.0", - "phpunit/phpunit": "^9.0", - "phing/phing": "^2.16", + "ergebnis/composer-normalize": "^2.5", "fzaninotto/faker": "^1.7", - "phpstan/phpstan": "^0.12.3", "mockery/mockery": "^1.3", + "phing/phing": "^2.16", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.12.3", + "phpstan/phpstan-deprecation-rules": "^0.12.2", + "phpstan/phpstan-phpunit": "^0.12.8", + "phpstan/phpstan-strict-rules": "^0.12.2", + "phpunit/phpunit": "^9.0", + "slevomat/coding-standard": "^6.0", "sllh/composer-versions-check": "^2.0", "php-parallel-lint/php-parallel-lint": "^1.2" }, + "config": { + "sort-packages": true + }, "autoload": { "psr-4": { - "EcomailFlexibee\\": ["src/"], - "EcomailFlexibeeTest\\": ["tests/"] + "EcomailFlexibee\\": [ + "src/" + ], + "EcomailFlexibeeTest\\": [ + "tests/" + ] } }, "autoload-dev": { - "classmap": ["tests/"] + "classmap": [ + "tests/" + ] }, - "config": { - "sort-packages": true - } + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/composer.lock b/composer.lock index bdb60a5..305f411 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3637ac05c3ccca5cce944e4e7454c335", + "content-hash": "8930239a10695760cce334fbb9a57fe6", "packages": [ { "name": "consistence/consistence", @@ -215,6 +215,186 @@ ], "time": "2020-05-29T17:27:14+00:00" }, + { + "name": "ergebnis/composer-normalize", + "version": "2.5.1", + "source": { + "type": "git", + "url": "https://github.com/ergebnis/composer-normalize.git", + "reference": "d0faf549e565757a7ffbf1f306a4293080e43bdd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ergebnis/composer-normalize/zipball/d0faf549e565757a7ffbf1f306a4293080e43bdd", + "reference": "d0faf549e565757a7ffbf1f306a4293080e43bdd", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.1.0 || ^2.0.0", + "ergebnis/json-normalizer": "~0.12.0", + "ergebnis/json-printer": "^3.0.2", + "localheinz/diff": "^1.0.1", + "php": "^7.1" + }, + "require-dev": { + "composer/composer": "^1.10.5 || ^2.0.0", + "composer/package-versions-deprecated": "^1.8.0", + "ergebnis/phpstan-rules": "~0.14.4", + "ergebnis/test-util": "~1.0.0", + "jangregor/phpstan-prophecy": "~0.6.2", + "phpstan/extension-installer": "^1.0.4", + "phpstan/phpstan": "~0.12.19", + "phpstan/phpstan-deprecation-rules": "~0.12.2", + "phpstan/phpstan-phpunit": "~0.12.8", + "phpstan/phpstan-strict-rules": "~0.12.2", + "phpunit/phpunit": "^7.5.20", + "symfony/filesystem": "^4.4.8" + }, + "type": "composer-plugin", + "extra": { + "class": "Ergebnis\\Composer\\Normalize\\NormalizePlugin" + }, + "autoload": { + "psr-4": { + "Ergebnis\\Composer\\Normalize\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Möller", + "email": "am@localheinz.com" + } + ], + "description": "Provides a composer plugin for normalizing composer.json.", + "homepage": "https://github.com/ergebnis/composer-normalize", + "keywords": [ + "composer", + "normalize", + "normalizer", + "plugin" + ], + "time": "2020-05-01T12:02:09+00:00" + }, + { + "name": "ergebnis/json-normalizer", + "version": "0.12.0", + "source": { + "type": "git", + "url": "https://github.com/ergebnis/json-normalizer.git", + "reference": "0197447cd5d8f7e82116e904196a3e9f470655db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ergebnis/json-normalizer/zipball/0197447cd5d8f7e82116e904196a3e9f470655db", + "reference": "0197447cd5d8f7e82116e904196a3e9f470655db", + "shasum": "" + }, + "require": { + "ergebnis/json-printer": "^3.0.2", + "ext-json": "*", + "justinrainbow/json-schema": "^4.0.0 || ^5.0.0", + "php": "^7.1" + }, + "require-dev": { + "ergebnis/license": "~0.1.0", + "ergebnis/php-cs-fixer-config": "^2.1.2", + "ergebnis/phpstan-rules": "~0.14.4", + "ergebnis/test-util": "~1.0.0", + "infection/infection": "~0.13.6", + "jangregor/phpstan-prophecy": "~0.6.2", + "phpstan/extension-installer": "^1.0.4", + "phpstan/phpstan": "~0.12.18", + "phpstan/phpstan-deprecation-rules": "~0.12.2", + "phpstan/phpstan-phpunit": "~0.12.8", + "phpstan/phpstan-strict-rules": "~0.12.2", + "phpunit/phpunit": "^7.5.20", + "psalm/plugin-phpunit": "~0.10.0", + "vimeo/psalm": "^3.11.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Ergebnis\\Json\\Normalizer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Möller", + "email": "am@localheinz.com" + } + ], + "description": "Provides generic and vendor-specific normalizers for normalizing JSON documents.", + "homepage": "https://github.com/ergebnis/json-normalizer", + "keywords": [ + "json", + "normalizer" + ], + "time": "2020-04-19T12:30:41+00:00" + }, + { + "name": "ergebnis/json-printer", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/ergebnis/json-printer.git", + "reference": "c7985dc4879777f2e4ab689da25bdd49f59dd2cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ergebnis/json-printer/zipball/c7985dc4879777f2e4ab689da25bdd49f59dd2cb", + "reference": "c7985dc4879777f2e4ab689da25bdd49f59dd2cb", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "php": "^7.1" + }, + "require-dev": { + "ergebnis/php-cs-fixer-config": "~1.1.1", + "ergebnis/phpstan-rules": "~0.14.1", + "ergebnis/test-util": "~0.9.0", + "infection/infection": "~0.13.6", + "phpbench/phpbench": "~0.16.10", + "phpstan/extension-installer": "^1.0.3", + "phpstan/phpstan": "~0.11.19", + "phpstan/phpstan-deprecation-rules": "~0.11.2", + "phpstan/phpstan-strict-rules": "~0.11.1", + "phpunit/phpunit": "^7.5.18" + }, + "type": "library", + "autoload": { + "psr-4": { + "Ergebnis\\Json\\Printer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Möller", + "email": "am@localheinz.com" + } + ], + "description": "Provides a JSON printer, allowing for flexible indentation.", + "homepage": "https://github.com/ergebnis/json-printer", + "keywords": [ + "formatter", + "json", + "printer" + ], + "time": "2019-12-19T14:42:54+00:00" + }, { "name": "fzaninotto/faker", "version": "v1.9.1", @@ -313,6 +493,123 @@ ], "time": "2016-01-20T08:20:44+00:00" }, + { + "name": "justinrainbow/json-schema", + "version": "5.2.9", + "source": { + "type": "git", + "url": "https://github.com/justinrainbow/json-schema.git", + "reference": "44c6787311242a979fa15c704327c20e7221a0e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/44c6787311242a979fa15c704327c20e7221a0e4", + "reference": "44c6787311242a979fa15c704327c20e7221a0e4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.2.20||~2.15.1", + "json-schema/json-schema-test-suite": "1.2.0", + "phpunit/phpunit": "^4.8.35" + }, + "bin": [ + "bin/validate-json" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "JsonSchema\\": "src/JsonSchema/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bruno Prieto Reis", + "email": "bruno.p.reis@gmail.com" + }, + { + "name": "Justin Rainbow", + "email": "justin.rainbow@gmail.com" + }, + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + }, + { + "name": "Robert Schönthal", + "email": "seroscho@googlemail.com" + } + ], + "description": "A library to validate a json schema.", + "homepage": "https://github.com/justinrainbow/json-schema", + "keywords": [ + "json", + "schema" + ], + "time": "2019-09-25T14:49:45+00:00" + }, + { + "name": "localheinz/diff", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/localheinz/diff.git", + "reference": "bd5661db4bbed26c6f25df8851fd9f4b424a356e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/localheinz/diff/zipball/bd5661db4bbed26c6f25df8851fd9f4b424a356e", + "reference": "bd5661db4bbed26c6f25df8851fd9f4b424a356e", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.5 || ^8.0", + "symfony/process": "^2 || ^3.3 || ^4" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Fork of sebastian/diff for use with ergebnis/composer-normalize", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "time": "2019-12-17T07:42:37+00:00" + }, { "name": "mockery/mockery", "version": "1.4.0", @@ -888,6 +1185,51 @@ ], "time": "2020-03-05T15:02:03+00:00" }, + { + "name": "phpstan/extension-installer", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "2e041def501d661b806f50000c8a4dccbd4907b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/2e041def501d661b806f50000c8a4dccbd4907b4", + "reference": "2e041def501d661b806f50000c8a4dccbd4907b4", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.1 || ^2.0", + "php": "^7.1", + "phpstan/phpstan": ">=0.11.6" + }, + "require-dev": { + "composer/composer": "^1.8", + "consistence/coding-standard": "^3.8", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "ergebnis/composer-normalize": "^2.0.2", + "jakub-onderka/php-parallel-lint": "^1.0", + "phing/phing": "^2.16", + "phpstan/phpstan-strict-rules": "^0.11", + "slevomat/coding-standard": "^5.0.4" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "time": "2020-03-31T16:00:42+00:00" + }, { "name": "phpstan/phpdoc-parser", "version": "0.4.4", @@ -979,6 +1321,164 @@ "description": "PHPStan - PHP Static Analysis Tool", "time": "2020-05-10T20:36:16+00:00" }, + { + "name": "phpstan/phpstan-deprecation-rules", + "version": "0.12.2", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", + "reference": "51d21a83b97e539e1fc56c1ce42ac0f187407fb6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/51d21a83b97e539e1fc56c1ce42ac0f187407fb6", + "reference": "51d21a83b97e539e1fc56c1ce42ac0f187407fb6", + "shasum": "" + }, + "require": { + "php": "~7.1", + "phpstan/phpstan": "^0.12" + }, + "require-dev": { + "consistence/coding-standard": "^3.0.1", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "jakub-onderka/php-parallel-lint": "^1.0", + "localheinz/composer-normalize": "^1.3.0", + "phing/phing": "^2.16.0", + "phpstan/phpstan-phpunit": "^0.12", + "phpunit/phpunit": "^7.0", + "slevomat/coding-standard": "^4.5.2" + }, + "type": "phpstan-extension", + "extra": { + "branch-alias": { + "dev-master": "0.12-dev" + }, + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", + "time": "2020-01-12T16:25:40+00:00" + }, + { + "name": "phpstan/phpstan-phpunit", + "version": "0.12.8", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-phpunit.git", + "reference": "7232c17e2493dc598173da784477ce0afb2c4e0e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/7232c17e2493dc598173da784477ce0afb2c4e0e", + "reference": "7232c17e2493dc598173da784477ce0afb2c4e0e", + "shasum": "" + }, + "require": { + "php": "~7.1", + "phpstan/phpstan": "^0.12.6" + }, + "conflict": { + "phpunit/phpunit": "<7.0" + }, + "require-dev": { + "consistence/coding-standard": "^3.5", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "ergebnis/composer-normalize": "^2.0.2", + "jakub-onderka/php-parallel-lint": "^1.0", + "phing/phing": "^2.16.0", + "phpstan/phpstan-strict-rules": "^0.12", + "phpunit/phpunit": "^7.0", + "satooshi/php-coveralls": "^1.0", + "slevomat/coding-standard": "^4.7.2" + }, + "type": "phpstan-extension", + "extra": { + "branch-alias": { + "dev-master": "0.12-dev" + }, + "phpstan": { + "includes": [ + "extension.neon", + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPUnit extensions and rules for PHPStan", + "time": "2020-04-17T08:04:10+00:00" + }, + { + "name": "phpstan/phpstan-strict-rules", + "version": "0.12.2", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-strict-rules.git", + "reference": "a670a59aff7cf96f75d21b974860ada10e25b2ee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/a670a59aff7cf96f75d21b974860ada10e25b2ee", + "reference": "a670a59aff7cf96f75d21b974860ada10e25b2ee", + "shasum": "" + }, + "require": { + "php": "~7.1", + "phpstan/phpstan": "^0.12.6" + }, + "require-dev": { + "consistence/coding-standard": "^3.0.1", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "ergebnis/composer-normalize": "^2.0.2", + "jakub-onderka/php-parallel-lint": "^1.0", + "phing/phing": "^2.16.0", + "phpstan/phpstan-phpunit": "^0.12", + "phpunit/phpunit": "^7.0", + "slevomat/coding-standard": "^4.5.2" + }, + "type": "phpstan-extension", + "extra": { + "branch-alias": { + "dev-master": "0.12-dev" + }, + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Extra strict and opinionated rules for PHPStan", + "time": "2020-01-20T13:08:52+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "8.0.2", @@ -2346,11 +2846,11 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "ext-simplexml": "*", + "php": "^7.4", "ext-curl": "*", - "ext-mbstring": "*", "ext-json": "*", - "php": "^7.4" + "ext-mbstring": "*", + "ext-simplexml": "*" }, "platform-dev": [] } diff --git a/src/Http/HttpClient.php b/src/Http/HttpClient.php index 5db67e9..d0ee892 100644 --- a/src/Http/HttpClient.php +++ b/src/Http/HttpClient.php @@ -48,7 +48,7 @@ public function request( $output = \curl_exec($ch); $output = \is_string($output) ? $output : null; - $errorMessage = \mb_strlen(\trim(\curl_error($ch))) + $errorMessage = \mb_strlen(\trim(\curl_error($ch))) > 0 ? null : \curl_error($ch); diff --git a/src/RecurringContractClient.php b/src/RecurringContractClient.php deleted file mode 100644 index ebacae3..0000000 --- a/src/RecurringContractClient.php +++ /dev/null @@ -1,34 +0,0 @@ -getUrl(), - $config->getCompany(), - $config->getUser(), - $config->getPassword(), - self::EVIDENCE, - $config->isSelfSignedCertificate(), - $config->getAuthSessionId(), - ); - } - - public function generateInvoices(): bool - { - /** @var \EcomailFlexibee\Result\EvidenceResult $result */ - $result = $this->callRequest(Method::get(Method::POST), 'generovani-faktur', [], [], [])[0]; - $statusCode = $result->getData()['status_code']; - - return $statusCode >= 200 && $statusCode <= 299; - } - -} diff --git a/tests/RecurringContractClientTest.php b/tests/RecurringContractClientTest.php deleted file mode 100644 index 4e8d2ff..0000000 --- a/tests/RecurringContractClientTest.php +++ /dev/null @@ -1,38 +0,0 @@ -config = new \EcomailFlexibee\Config( - Config::HOST, - Config::COMPANY, - Config::USERNAME, - Config::PASSWORD, - 'smlouvy', - false, - null, - ); - } - - public function testBackup(): void - { - /** @var \EcomailFlexibee\RecurringContractClient|\Mockery\MockInterface $bankClientMock */ - $bankClientMock = Mockery::mock(RecurringContractClient::class, [$this->config])->makePartial(); - $bankClientMock->shouldReceive('generateInvoices')->andReturnTrue(); - Assert::assertTrue($bankClientMock->generateInvoices()); - } -} From 96545069fe72788a8659d70d978dfc68c16c3993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kr=C3=A1l?= Date: Wed, 20 May 2020 20:04:58 +0200 Subject: [PATCH 4/7] Client - enable log requests --- .gitignore | 1 + composer.json | 1 + composer.lock | 86 ++++++++++++++++++++++++++++++++- src/Client.php | 4 +- src/Config.php | 13 ++++- src/Http/HttpClient.php | 32 +++++++++++- tests/ClientTest.php | 20 ++++++++ tests/logs/log.log/logs/log.log | 1 + 8 files changed, 152 insertions(+), 6 deletions(-) create mode 100644 tests/logs/log.log/logs/log.log diff --git a/.gitignore b/.gitignore index 4a00a08..52aac44 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /.idea /vendor +/logs .DS_Store tests/.DS_Store .phpunit.result.cache diff --git a/composer.json b/composer.json index df24182..bda5fb6 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "ext-simplexml": "*", "consistence/consistence": "^2.0", "jwage/purl": "^1.0", + "league/flysystem": "^1.0", "rakit/validation": "^1.1" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 305f411..c5aa91c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8930239a10695760cce334fbb9a57fe6", + "content-hash": "622a5d7318ec6a9bac672c7e77ac7ea3", "packages": [ { "name": "consistence/consistence", @@ -116,6 +116,90 @@ ], "time": "2019-04-11T18:45:04+00:00" }, + { + "name": "league/flysystem", + "version": "1.0.69", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/flysystem.git", + "reference": "7106f78428a344bc4f643c233a94e48795f10967" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/7106f78428a344bc4f643c233a94e48795f10967", + "reference": "7106f78428a344bc4f643c233a94e48795f10967", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "php": ">=5.5.9" + }, + "conflict": { + "league/flysystem-sftp": "<1.0.6" + }, + "require-dev": { + "phpspec/phpspec": "^3.4", + "phpunit/phpunit": "^5.7.26" + }, + "suggest": { + "ext-fileinfo": "Required for MimeType", + "ext-ftp": "Allows you to use FTP server storage", + "ext-openssl": "Allows you to use FTPS server storage", + "league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2", + "league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3", + "league/flysystem-azure": "Allows you to use Windows Azure Blob storage", + "league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching", + "league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem", + "league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files", + "league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib", + "league/flysystem-webdav": "Allows you to use WebDAV storage", + "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter", + "spatie/flysystem-dropbox": "Allows you to use Dropbox storage", + "srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Flysystem\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frenky.net" + } + ], + "description": "Filesystem abstraction: Many filesystems, one API.", + "keywords": [ + "Cloud Files", + "WebDAV", + "abstraction", + "aws", + "cloud", + "copy.com", + "dropbox", + "file systems", + "files", + "filesystem", + "filesystems", + "ftp", + "rackspace", + "remote", + "s3", + "sftp", + "storage" + ], + "time": "2020-05-18T15:13:39+00:00" + }, { "name": "rakit/validation", "version": "v1.2.0", diff --git a/src/Client.php b/src/Client.php index f5d0ee8..ca7087a 100644 --- a/src/Client.php +++ b/src/Client.php @@ -28,7 +28,8 @@ public function __construct( string $password, string $evidence, bool $selfSignedCertificate, - ?string $authSessionId = null + ?string $authSessionId = null, + ?string $logFilePath = null ) { $this->config = new Config( @@ -39,6 +40,7 @@ public function __construct( $evidence, $selfSignedCertificate, $authSessionId, + $logFilePath, ); $this->queryBuilder = new UrlBuilder($this->config); $this->responseHydrator = new ResponseHydrator($this->config); diff --git a/src/Config.php b/src/Config.php index b9ba275..cc48764 100644 --- a/src/Config.php +++ b/src/Config.php @@ -17,7 +17,9 @@ final class Config private bool $selfSignedCertificate; - private ?string $authSessionId = null; + private ?string $authSessionId; + + private ?string $logFilePath; public function __construct( string $url, @@ -26,7 +28,8 @@ public function __construct( string $password, string $evidence, bool $selfSignedCertificate, - ?string $authSessionId = null + ?string $authSessionId = null, + ?string $logFilePath = null ) { $this->url = $url; @@ -36,6 +39,7 @@ public function __construct( $this->evidence = $evidence; $this->selfSignedCertificate = $selfSignedCertificate; $this->authSessionId = $authSessionId; + $this->logFilePath = $logFilePath; } public function getUrl(): string @@ -73,4 +77,9 @@ public function getAuthSessionId(): ?string return $this->authSessionId; } + public function getLogFilePath(): ?string + { + return $this->logFilePath; + } + } diff --git a/src/Http/HttpClient.php b/src/Http/HttpClient.php index d0ee892..74facfb 100644 --- a/src/Http/HttpClient.php +++ b/src/Http/HttpClient.php @@ -3,6 +3,8 @@ namespace EcomailFlexibee\Http; use EcomailFlexibee\Config; +use League\Flysystem\Adapter\Local; +use League\Flysystem\Filesystem; final class HttpClient { @@ -46,17 +48,43 @@ public function request( $config, ); + $startTime = \microtime(true); $output = \curl_exec($ch); + $responseTime = \microtime(true) - $startTime; $output = \is_string($output) ? $output : null; - $errorMessage = \mb_strlen(\trim(\curl_error($ch))) > 0 + $errorMessage = \mb_strlen(\trim(\curl_error($ch))) === 0 ? null : \curl_error($ch); + $statusCode = \curl_getinfo($ch, \CURLINFO_HTTP_CODE); + + if ($config->getLogFilePath() !== null) { + $rootDir = \dirname($config->getLogFilePath()); + $fileSystem = new Filesystem(new Local($rootDir, \FILE_APPEND)); + $logContent = \sprintf( + '%s METHOD: %s URL:%s TIME:%s STATUS:%s', + \date('Y-m-d H:i:s'), + $httpMethod->getValue(), + $url, + \number_format($responseTime, 2), + $statusCode, + ); + + if ($errorMessage !== null) { + $logContent = \sprintf('%s ERROR:%s', $logContent, $errorMessage); + } + + $logContent .= "\n"; + $fileSystem->put( + \basename($config->getLogFilePath()), + $logContent, + ); + } return ResponseFactory::createFromOutput( $url, $httpMethod, $output, - \curl_getinfo($ch, \CURLINFO_HTTP_CODE), + $statusCode, \curl_errno($ch), $errorMessage, ); diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 7cf3297..bf49515 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -300,4 +300,24 @@ public function testGetPropertiesForEvidence(): void Assert::assertArrayHasKey('property', $responseData['properties']); } + public function testLogRequest(): void + { + $logPath = 'logs/log.txt'; + @\unlink($logPath); + $client = new Client( + Config::HOST, + Config::COMPANY, + Config::USERNAME, + Config::PASSWORD, + 'faktura-vydana', + false, + null, + $logPath, + ); + $client->allInEvidence(); + + Assert::assertTrue(\file_exists($logPath)); + Assert::assertNotEmpty(\file_get_contents($logPath)); + } + } diff --git a/tests/logs/log.log/logs/log.log b/tests/logs/log.log/logs/log.log new file mode 100644 index 0000000..ac8522f --- /dev/null +++ b/tests/logs/log.log/logs/log.log @@ -0,0 +1 @@ +xxx \ No newline at end of file From 8b8753829a2e36bf1013d5924fe0549550fbf4b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kr=C3=A1l?= Date: Thu, 21 May 2020 08:53:26 +0200 Subject: [PATCH 5/7] Update readme.md --- README.md | 9 ++------ src/BankClient.php | 43 ----------------------------------- tests/BankClientTest.php | 49 ---------------------------------------- 3 files changed, 2 insertions(+), 99 deletions(-) delete mode 100644 src/BankClient.php delete mode 100644 tests/BankClientTest.php diff --git a/README.md b/README.md index 5aee08a..21172ed 100644 --- a/README.md +++ b/README.md @@ -19,19 +19,14 @@ $restApiPassword, $evidenceName, $enableSelfSignedCertificate, $authSessionId, +$logPath, ); ``` `$enableSelfSignedCertificate - Vyžadání self signed certifikátu` `$authSessionId - Hodnota authentikačního id pro Flexibee` -## Typy klientů -K dispozici jsou různé druhy klientů, které mají implementovány metody pro snažší práci s FlexiBee API. -``` -$bankClient = new BankClient($config); -$companyClient = new CompanyClient($config); -$recurringContractClient = new RecurringContractClient($config); -``` +`$logPath - Cesta souboru pro logování requestů` ## Vygenerování autorizačního tokenu ``` diff --git a/src/BankClient.php b/src/BankClient.php deleted file mode 100644 index 051b45a..0000000 --- a/src/BankClient.php +++ /dev/null @@ -1,43 +0,0 @@ -getUrl(), - $config->getCompany(), - $config->getUser(), - $config->getPassword(), - self::EVIDENCE, - $config->isSelfSignedCertificate(), - $config->getAuthSessionId(), - ); - } - - public function downloadOnlineListings(): bool - { - /** @var \EcomailFlexibee\Result\EvidenceResult $result */ - $result = $this->callRequest(Method::get(Method::POST), 'nacteni-vypisu-online', [], [], [])[0]; - $statusCode = $result->getData()['status_code']; - - return $statusCode >= 200 && $statusCode <= 299; - } - - public function automaticPairing(): bool - { - /** @var \EcomailFlexibee\Result\EvidenceResult $result */ - $result = $this->callRequest(Method::get(Method::POST), 'automaticke-parovani', [], [], [])[0]; - $statusCode = $result->getData()['status_code']; - - return $statusCode >= 200 && $statusCode <= 299; - } - -} diff --git a/tests/BankClientTest.php b/tests/BankClientTest.php deleted file mode 100644 index 2bba838..0000000 --- a/tests/BankClientTest.php +++ /dev/null @@ -1,49 +0,0 @@ -config = new \EcomailFlexibee\Config( - Config::HOST, - Config::COMPANY, - Config::USERNAME, - Config::PASSWORD, - 'banka', - false, - null, - ); - } - - public function testDownloadOnlineListingsMock(): void - { - /** @var \EcomailFlexibee\BankClient|\Mockery\MockInterface $bankClientMock */ - $bankClientMock = Mockery::mock(BankClient::class, [$this->config])->makePartial(); - $bankClientMock->shouldReceive('downloadOnlineListings')->andReturnTrue(); - Assert::assertTrue($bankClientMock->downloadOnlineListings()); - } - - public function testAutomaticPairing(): void - { - /** @var \EcomailFlexibee\BankClient|\Mockery\MockInterface $bankClientMock */ - $bankClientMock = Mockery::mock(BankClient::class, [$this->config])->makePartial(); - $bankClientMock->shouldReceive('automaticPairing')->andReturnTrue(); - Assert::assertTrue($bankClientMock->automaticPairing()); - } - -} From 1d6836b01f06541e9fc1ad548638c7b79ca48fe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kr=C3=A1l?= Date: Sun, 31 May 2020 11:52:22 +0200 Subject: [PATCH 6/7] Client - fixed property names with small fixies --- README.md | 4 ++-- src/Client.php | 4 ++-- src/CompanyClient.php | 2 +- src/Config.php | 17 ++++--------- src/Http/HttpClient.php | 1 - src/Http/HttpCurlBuilder.php | 2 +- tests/CompanyClientTest.php | 46 ------------------------------------ 7 files changed, 11 insertions(+), 65 deletions(-) delete mode 100644 tests/CompanyClientTest.php diff --git a/README.md b/README.md index 21172ed..45591e8 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,12 @@ $companyCode, $restApiUserName, $restApiPassword, $evidenceName, -$enableSelfSignedCertificate, +$disableSelfSignedCertificate, $authSessionId, $logPath, ); ``` -`$enableSelfSignedCertificate - Vyžadání self signed certifikátu` +`$disableSelfSignedCertificate - Vypnutí self signed certifikátu` `$authSessionId - Hodnota authentikačního id pro Flexibee` diff --git a/src/Client.php b/src/Client.php index ca7087a..2690819 100644 --- a/src/Client.php +++ b/src/Client.php @@ -27,7 +27,7 @@ public function __construct( string $user, string $password, string $evidence, - bool $selfSignedCertificate, + bool $disableSelfSignedCertificate, ?string $authSessionId = null, ?string $logFilePath = null ) @@ -38,7 +38,7 @@ public function __construct( $user, $password, $evidence, - $selfSignedCertificate, + $disableSelfSignedCertificate, $authSessionId, $logFilePath, ); diff --git a/src/CompanyClient.php b/src/CompanyClient.php index 9c4a704..13e113e 100644 --- a/src/CompanyClient.php +++ b/src/CompanyClient.php @@ -18,7 +18,7 @@ public function __construct(Config $config) $config->getUser(), $config->getPassword(), self::EVIDENCE, - $config->isSelfSignedCertificate(), + $config->isDisableSelfSignedCertificate(), $config->getAuthSessionId(), ); } diff --git a/src/Config.php b/src/Config.php index cc48764..df44b05 100644 --- a/src/Config.php +++ b/src/Config.php @@ -6,19 +6,12 @@ final class Config { private string $url; - private string $company; - private string $user; - private string $password; - private string $evidence; - - private bool $selfSignedCertificate; - + private bool $disableSelfSignedCertificate; private ?string $authSessionId; - private ?string $logFilePath; public function __construct( @@ -27,7 +20,7 @@ public function __construct( string $user, string $password, string $evidence, - bool $selfSignedCertificate, + bool $disableSelfSignedCertificate, ?string $authSessionId = null, ?string $logFilePath = null ) @@ -37,7 +30,7 @@ public function __construct( $this->user = $user; $this->password = $password; $this->evidence = $evidence; - $this->selfSignedCertificate = $selfSignedCertificate; + $this->disableSelfSignedCertificate = $disableSelfSignedCertificate; $this->authSessionId = $authSessionId; $this->logFilePath = $logFilePath; } @@ -67,9 +60,9 @@ public function getEvidence(): string return $this->evidence; } - public function isSelfSignedCertificate(): bool + public function isDisableSelfSignedCertificate(): bool { - return $this->selfSignedCertificate; + return $this->disableSelfSignedCertificate; } public function getAuthSessionId(): ?string diff --git a/src/Http/HttpClient.php b/src/Http/HttpClient.php index 74facfb..7c132e5 100644 --- a/src/Http/HttpClient.php +++ b/src/Http/HttpClient.php @@ -10,7 +10,6 @@ final class HttpClient { private \EcomailFlexibee\Http\UrlNormalizer $urlNormalizer; - private \EcomailFlexibee\Http\HttpCurlBuilder $httpCurlBuilder; public function __construct() { diff --git a/src/Http/HttpCurlBuilder.php b/src/Http/HttpCurlBuilder.php index 6dcea0b..110593d 100644 --- a/src/Http/HttpCurlBuilder.php +++ b/src/Http/HttpCurlBuilder.php @@ -32,7 +32,7 @@ public function build(string $url, Method $httpMethod, array $postFields, array \curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, $httpMethod->getValue()); \curl_setopt($ch, \CURLOPT_USERAGENT, 'Ecomail.cz Flexibee client (https://github.com/Ecomailcz/flexibee-client)'); - if ($config->isSelfSignedCertificate() || $config->getAuthSessionId() !== null) { + if ($config->isDisableSelfSignedCertificate() || $config->getAuthSessionId() !== null) { \curl_setopt($ch, \CURLOPT_SSL_VERIFYPEER, FALSE); \curl_setopt($ch, \CURLOPT_SSL_VERIFYHOST, FALSE); } diff --git a/tests/CompanyClientTest.php b/tests/CompanyClientTest.php deleted file mode 100644 index a5b79aa..0000000 --- a/tests/CompanyClientTest.php +++ /dev/null @@ -1,46 +0,0 @@ -config = new \EcomailFlexibee\Config( - Config::HOST, - Config::COMPANY, - Config::USERNAME, - Config::PASSWORD, - 'c', - false, - null, - ); - } - - public function testBackup(): void - { - /** @var \EcomailFlexibee\CompanyClient|\Mockery\MockInterface $bankClientMock */ - $bankClientMock = Mockery::mock(BankClient::class, [$this->config])->makePartial(); - $bankClientMock->shouldReceive('backup')->andReturnTrue(); - Assert::assertTrue($bankClientMock->backup()); - } - - public function testAutomaticPairing(): void - { - /** @var \EcomailFlexibee\CompanyClient|\Mockery\MockInterface $bankClientMock */ - $bankClientMock = Mockery::mock(BankClient::class, [$this->config])->makePartial(); - $bankClientMock->shouldReceive('restore')->andReturnTrue(); - Assert::assertTrue($bankClientMock->restore('demo', '')); - } -} From 985a24015184e230d0f80e7e8f9e1525f75bea37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kr=C3=A1l?= Date: Sun, 31 May 2020 12:59:54 +0200 Subject: [PATCH 7/7] PHPCS - fixies --- composer.json | 4 ++-- composer.lock | 5 +++-- ruleset.xml | 11 +---------- src/Client.php | 26 +------------------------- src/Http/Response/FlexibeeResponse.php | 6 ------ src/Http/ResponseFactory.php | 1 - src/Http/ResponseHydrator.php | 5 +---- src/Http/UrlBuilder.php | 12 ------------ 8 files changed, 8 insertions(+), 62 deletions(-) diff --git a/composer.json b/composer.json index bda5fb6..29d07a6 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,7 @@ "fzaninotto/faker": "^1.7", "mockery/mockery": "^1.3", "phing/phing": "^2.16", + "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^0.12.3", "phpstan/phpstan-deprecation-rules": "^0.12.2", @@ -27,8 +28,7 @@ "phpstan/phpstan-strict-rules": "^0.12.2", "phpunit/phpunit": "^9.0", "slevomat/coding-standard": "^6.0", - "sllh/composer-versions-check": "^2.0", - "php-parallel-lint/php-parallel-lint": "^1.2" + "sllh/composer-versions-check": "^2.0" }, "config": { "sort-packages": true diff --git a/composer.lock b/composer.lock index c5aa91c..97831a8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "622a5d7318ec6a9bac672c7e77ac7ea3", + "content-hash": "189d878955925fa3a836318f6de52a99", "packages": [ { "name": "consistence/consistence", @@ -2936,5 +2936,6 @@ "ext-mbstring": "*", "ext-simplexml": "*" }, - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "1.1.0" } diff --git a/ruleset.xml b/ruleset.xml index ed03d30..22aed67 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -1,5 +1,5 @@ - + @@ -163,13 +163,4 @@ - - - - - - - - - diff --git a/src/Client.php b/src/Client.php index 2690819..3cc683e 100644 --- a/src/Client.php +++ b/src/Client.php @@ -97,7 +97,6 @@ public function getAllApiChanges(?string $fromVersion): Response /** * @param array $parameters - * @return string */ public function getLoginFormUrl(array $parameters): string { @@ -149,9 +148,7 @@ public function deleteByCode(string $id, bool $dryRun = false): void } /** - * @param int $id * @param array $uriParameters - * @return \EcomailFlexibee\Result\EvidenceResult * @throws \EcomailFlexibee\Exception\EcomailFlexibeeConnectionError * @throws \EcomailFlexibee\Exception\EcomailFlexibeeForbidden * @throws \EcomailFlexibee\Exception\EcomailFlexibeeInvalidAuthorization @@ -169,9 +166,7 @@ public function findById(int $id, array $uriParameters = []): EvidenceResult } /** - * @param string $code * @param array $uriParameters - * @return \EcomailFlexibee\Result\EvidenceResult * @throws \EcomailFlexibee\Exception\EcomailFlexibeeConnectionError * @throws \EcomailFlexibee\Exception\EcomailFlexibeeForbidden * @throws \EcomailFlexibee\Exception\EcomailFlexibeeInvalidAuthorization @@ -197,9 +192,7 @@ public function getByCode(string $code, array $uriParameters = []): EvidenceResu } /** - * @param int $id * @param array $uriParameters - * @return \EcomailFlexibee\Result\EvidenceResult * @throws \EcomailFlexibee\Exception\EcomailFlexibeeConnectionError * @throws \EcomailFlexibee\Exception\EcomailFlexibeeForbidden * @throws \EcomailFlexibee\Exception\EcomailFlexibeeInvalidAuthorization @@ -224,9 +217,7 @@ public function getById(int $id, array $uriParameters = []): EvidenceResult } /** - * @param string $code * @param array $uriParameters - * @return \EcomailFlexibee\Result\EvidenceResult * @throws \EcomailFlexibee\Exception\EcomailFlexibeeConnectionError * @throws \EcomailFlexibee\Exception\EcomailFlexibeeForbidden * @throws \EcomailFlexibee\Exception\EcomailFlexibeeInvalidAuthorization @@ -246,10 +237,7 @@ public function findByCode(string $code, array $uriParameters = []): EvidenceRes /** * @param array $evidenceData - * @param int|null $id - * @param bool $dryRun * @param array $uriParameters - * @return \EcomailFlexibee\Http\Response\FlexibeeResponse * @throws \EcomailFlexibee\Exception\EcomailFlexibeeConnectionError * @throws \EcomailFlexibee\Exception\EcomailFlexibeeForbidden * @throws \EcomailFlexibee\Exception\EcomailFlexibeeInvalidAuthorization @@ -359,8 +347,6 @@ public function countInEvidence(): int } /** - * @param int $start - * @param int $limit * @return array<\EcomailFlexibee\Result\EvidenceResult> * @throws \EcomailFlexibee\Exception\EcomailFlexibeeConnectionError * @throws \EcomailFlexibee\Exception\EcomailFlexibeeForbidden @@ -384,7 +370,6 @@ public function chunkInEvidence(int $start, int $limit): array } /** - * @param string $query * @param array $uriParameters * @return array<\EcomailFlexibee\Result\EvidenceResult> * @throws \EcomailFlexibee\Exception\EcomailFlexibeeConnectionError @@ -409,7 +394,6 @@ public function searchInEvidence(string $query, array $uriParameters): array } /** - * @param \EcomailFlexibee\Http\Method $httpMethod * @param mixed $queryFilterOrId * @param array $uriParameters * @param array $postFields @@ -422,13 +406,7 @@ public function searchInEvidence(string $query, array $uriParameters): array * @throws \EcomailFlexibee\Exception\EcomailFlexibeeNotAcceptableRequest * @throws \EcomailFlexibee\Exception\EcomailFlexibeeRequestError */ - public function callRequest( - Method $httpMethod, - $queryFilterOrId, - array $uriParameters, - array $postFields, - array $headers - ): array + public function callRequest(Method $httpMethod, $queryFilterOrId, array $uriParameters, array $postFields, array $headers): array { $response = $this->httpClient->request( $this->queryBuilder->createUri($queryFilterOrId, $uriParameters), @@ -443,9 +421,7 @@ public function callRequest( } /** - * @param int $id * @param array $uriParameters - * @return \EcomailFlexibee\Http\Response\Response * @throws \EcomailFlexibee\Exception\EcomailFlexibeeConnectionError * @throws \EcomailFlexibee\Exception\EcomailFlexibeeForbidden * @throws \EcomailFlexibee\Exception\EcomailFlexibeeInvalidAuthorization diff --git a/src/Http/Response/FlexibeeResponse.php b/src/Http/Response/FlexibeeResponse.php index d11042d..191f265 100644 --- a/src/Http/Response/FlexibeeResponse.php +++ b/src/Http/Response/FlexibeeResponse.php @@ -30,12 +30,6 @@ class FlexibeeResponse implements Response /** * FlexibeeResponse constructor. * - * @param int $statusCode - * @param float|null $version - * @param bool $success - * @param string|null $message - * @param int $rowCount - * @param int|null $globalVersion * @param array $data * @param array $statistics */ diff --git a/src/Http/ResponseFactory.php b/src/Http/ResponseFactory.php index 2c866ae..927a6f1 100644 --- a/src/Http/ResponseFactory.php +++ b/src/Http/ResponseFactory.php @@ -130,7 +130,6 @@ public static function createFromOutput( /** * @param array $errors - * @param int $statusCode * @throws \EcomailFlexibee\Exception\EcomailFlexibeeRequestError */ private static function throwErrorMessage(array $errors, int $statusCode): void diff --git a/src/Http/ResponseHydrator.php b/src/Http/ResponseHydrator.php index 04d7d9c..c3611c9 100644 --- a/src/Http/ResponseHydrator.php +++ b/src/Http/ResponseHydrator.php @@ -20,7 +20,6 @@ public function __construct(Config $config) } /** - * @param \EcomailFlexibee\Http\Response\Response $response * @return array<\EcomailFlexibee\Result\EvidenceResult> * @throws \EcomailFlexibee\Exception\EcomailFlexibeeRequestError */ @@ -44,9 +43,7 @@ public function convertResponseToEvidenceResults(Response $response): array return [new EvidenceResult($data)]; } - return \array_map(static function (array $data) { - return new EvidenceResult($data); - }, $data[$this->config->getEvidence()]); + return \array_map(static fn (array $data) => new EvidenceResult($data), $data[$this->config->getEvidence()]); } public function convertResponseToEvidenceResult(Response $response, bool $throwException): EvidenceResult diff --git a/src/Http/UrlBuilder.php b/src/Http/UrlBuilder.php index 177d74a..fbbe43e 100644 --- a/src/Http/UrlBuilder.php +++ b/src/Http/UrlBuilder.php @@ -37,7 +37,6 @@ public function createAuthTokenUrl(): string /** * @param array $uriParameters - * @return string */ public function createLoginFormUrl(array $uriParameters): string { @@ -48,9 +47,7 @@ public function createLoginFormUrl(array $uriParameters): string } /** - * @param int $id * @param array $uriParameters - * @return string */ public function createPdfUrl(int $id, array $uriParameters): string { @@ -76,7 +73,6 @@ public function createRestoreUrl(string $companyName): string /** * @param array $uriParameters - * @return string */ public function createChangesUrl(array $uriParameters = []): string { @@ -95,7 +91,6 @@ public function createChangesStatusUrl(): string /** * @param array $uriParameters - * @return string */ public function createUriByEvidenceOnly(array $uriParameters): string { @@ -106,9 +101,7 @@ public function createUriByEvidenceOnly(array $uriParameters): string } /** - * @param string $filterQuery * @param array $uriParameters - * @return string */ public function createFilterQuery(string $filterQuery, array $uriParameters): string { @@ -119,9 +112,7 @@ public function createFilterQuery(string $filterQuery, array $uriParameters): st } /** - * @param string $code * @param array $uriParameters - * @return string * @throws \EcomailFlexibee\Exception\EcomailFlexibeeInvalidRequestParameter */ public function createUriByCodeOnly(string $code, array $uriParameters): string @@ -145,7 +136,6 @@ public function getUrl(): string /** * @param mixed $filterQueryOrId * @param array $uriParams - * @return string */ public function createUri($filterQueryOrId, array $uriParams): string { @@ -162,8 +152,6 @@ public function createUri($filterQueryOrId, array $uriParams): string /** * @param string|int $filterQueryOrId - * @param string $format - * @return \Purl\Path */ private function buildPathWithIdOrFilter($filterQueryOrId, string $format = 'json'): Path {