Skip to content

Commit

Permalink
test new versions of phpunit
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeynezbritskiy committed Dec 1, 2019
1 parent 891f97f commit b3b4eca
Show file tree
Hide file tree
Showing 70 changed files with 308 additions and 135 deletions.
4 changes: 3 additions & 1 deletion src/Api/AuthorizedRequestInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Api;

Expand Down
4 changes: 3 additions & 1 deletion src/Api/HttpResponseInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Api;

Expand Down
4 changes: 3 additions & 1 deletion src/Api/RequestInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Api;

Expand Down
4 changes: 3 additions & 1 deletion src/Api/ResponseInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Api;

Expand Down
4 changes: 3 additions & 1 deletion src/AuthorizedClient.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank;

Expand Down
4 changes: 3 additions & 1 deletion src/Base/AbstractAuthorizedRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Base;

Expand Down
4 changes: 3 additions & 1 deletion src/Base/AbstractPublicRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Base;

Expand Down
4 changes: 3 additions & 1 deletion src/Base/AbstractRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Base;

Expand Down
4 changes: 3 additions & 1 deletion src/Base/AbstractResponse.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Base;

Expand Down
39 changes: 26 additions & 13 deletions src/Base/Client.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Base;

use GuzzleHttp\Client as GuzzleHttpClient;
use GuzzleHttp\Exception\GuzzleException;
use SergeyNezbritskiy\PrivatBank\Request;

Expand Down Expand Up @@ -31,17 +34,23 @@ class Client
*/
public function request(string $request, array $params = array()): HttpResponse
{
$params = array_merge([
'method' => 'GET',
'query' => [],
'body' => '',
], $params);
$params = array_merge(
[
'method' => 'GET',
'query' => [],
'body' => '',
],
$params
);

$request = new Request($request, ...[
$request = new Request(
$request,
...[
$params['method'],
$params['query'],
$params['body'],
]);
]
);

return $this->send($request);
}
Expand All @@ -53,13 +62,17 @@ public function request(string $request, array $params = array()): HttpResponse
*/
public function send(Request $request): HttpResponse
{
$client = new \GuzzleHttp\Client();
$client = new GuzzleHttpClient();
$uri = $this->url . $request->getRequestUri();
try {
$response = $client->request($request->getMethod(), $uri, [
'query' => $request->getQuery(),
'body' => $request->getBody(),
]);
$response = $client->request(
$request->getMethod(),
$uri,
[
'query' => $request->getQuery(),
'body' => $request->getBody(),
]
);
$result = new HttpResponse(
$response->getBody()->getContents(),
$response->getStatusCode(),
Expand Down
4 changes: 3 additions & 1 deletion src/Base/HttpResponse.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Base;

Expand Down
4 changes: 3 additions & 1 deletion src/Base/PrivatBankApiException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Base;

Expand Down
14 changes: 9 additions & 5 deletions src/Base/Validator.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Base;

use InvalidArgumentException;

/**
* Class Validator
* @package SergeyNezbritskiy\PrivatBank\Base
*/
class Validator
{

const TYPE_REQUIRED = 'required';
const TYPE_DEFAULT = 'default';
public const TYPE_REQUIRED = 'required';
public const TYPE_DEFAULT = 'default';

/**
* @param array $params
Expand Down Expand Up @@ -41,7 +45,7 @@ private function validateParams(array &$params, $rule, array $fields, array $rul
case self::TYPE_REQUIRED:
foreach ($fields as $field) {
if (!array_key_exists($field, $params)) {
throw new \InvalidArgumentException("Argument $field required");
throw new InvalidArgumentException("Argument $field required");
}
}
break;
Expand All @@ -58,7 +62,7 @@ private function validateParams(array &$params, $rule, array $fields, array $rul
}
break;
default:
throw new \InvalidArgumentException("Unknown validator $rule");
throw new InvalidArgumentException("Unknown validator $rule");
}
}
}
4 changes: 3 additions & 1 deletion src/Merchant.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank;

Expand Down
4 changes: 3 additions & 1 deletion src/PublicClient.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank;

Expand Down
4 changes: 3 additions & 1 deletion src/Request.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank;

Expand Down
4 changes: 3 additions & 1 deletion src/Request/BalanceRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Request;

Expand Down
4 changes: 3 additions & 1 deletion src/Request/CheckPaymentMobileRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Request;

Expand Down
4 changes: 3 additions & 1 deletion src/Request/CheckPaymentRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Request;

Expand Down
13 changes: 8 additions & 5 deletions src/Request/ExchangeRatesArchiveRequest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Request;

use DateTime;
use InvalidArgumentException;
use SergeyNezbritskiy\PrivatBank\Api\HttpResponseInterface;
use SergeyNezbritskiy\PrivatBank\Api\ResponseInterface;
use SergeyNezbritskiy\PrivatBank\Base\AbstractPublicRequest;
use SergeyNezbritskiy\PrivatBank\Base\PrivatBankApiException;
use SergeyNezbritskiy\PrivatBank\Base\Validator;
use SergeyNezbritskiy\PrivatBank\Response\ExchangeRatesArchiveResponse;

Expand Down Expand Up @@ -42,7 +45,7 @@ public function getQuery(): array
/**
* @param HttpResponseInterface $httpResponse
* @return ResponseInterface
* @throws \SergeyNezbritskiy\PrivatBank\Base\PrivatBankApiException
* @throws PrivatBankApiException
*/
public function getResponse(HttpResponseInterface $httpResponse): ResponseInterface
{
Expand All @@ -56,9 +59,9 @@ protected function getValidationRules(): array
{
$callback = function ($params) {
$dateInput = $params['date'];
$date = DateTime::createFromFormat('d.m.Y', $params['date']);
$date = date_create_from_format('d.m.Y', $params['date']);
if (($date === false) || ($date->format('d.m.Y') !== $dateInput)) {
throw new \InvalidArgumentException('Argument date must conform format d.M.Y., e.g. 01.12.2018');
throw new InvalidArgumentException('Argument date must conform format d.M.Y., e.g. 01.12.2018');
}
};
return [
Expand Down
10 changes: 6 additions & 4 deletions src/Request/ExchangeRatesRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Request;

Expand All @@ -19,9 +21,9 @@
class ExchangeRatesRequest extends AbstractPublicRequest
{

const CASH = 5;
const NON_CASH = 11;
const NATIONAL_BANK_CASH = 3;
public const CASH = 5;
public const NON_CASH = 11;
public const NATIONAL_BANK_CASH = 3;

/**
* @return string
Expand Down
8 changes: 5 additions & 3 deletions src/Request/InfrastructureRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Request;

Expand All @@ -22,8 +24,8 @@
class InfrastructureRequest extends AbstractPublicRequest
{

const TYPE_ATM = 'atm';
const TYPE_TERMINAL = 'tso';
public const TYPE_ATM = 'atm';
public const TYPE_TERMINAL = 'tso';

/**
* @return string
Expand Down
4 changes: 3 additions & 1 deletion src/Request/OfficesRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Request;

Expand Down
4 changes: 3 additions & 1 deletion src/Request/PaymentInternalRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Request;

Expand Down
4 changes: 3 additions & 1 deletion src/Request/PaymentMobileRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Request;

Expand Down
4 changes: 3 additions & 1 deletion src/Request/PaymentUkraineRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Request;

Expand Down
4 changes: 3 additions & 1 deletion src/Request/PaymentVisaRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Request;

Expand Down
4 changes: 3 additions & 1 deletion src/Request/StatementsRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SergeyNezbritskiy\PrivatBank\Request;

Expand Down
Loading

0 comments on commit b3b4eca

Please sign in to comment.