Skip to content

Commit

Permalink
PHP downgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
mrprompt committed Dec 16, 2020
1 parent 4a164ad commit 0061073
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [7.4]
php: [7.2, 7.4]

name: P${{ matrix.php }}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "SDK de Integra\u0000\u0000o com a Im\u0000vel Web",
"type": "library",
"require": {
"php": "^7.4|^8",
"php": ">=7.2",
"ext-json": "*",
"ext-simplexml": "*",
"guzzlehttp/guzzle": "^7.2",
Expand Down
24 changes: 12 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions src/Base/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@

use GuzzleHttp\Exception\ClientException;
use InvalidArgumentException;
use JsonSchema\Validator;
use Psr\Http\Client\ClientInterface;

abstract class Base
{
protected ClientInterface $client;
protected const SEPARATOR = '|';
/**
* @var ClientInterface
*/
protected $client;

const SEPARATOR = '|';

/**
* Constructor
Expand Down Expand Up @@ -63,7 +68,7 @@ public function validate(string $namespace, array $data): bool
{
$schemaFile = $this->schema($namespace);

$validator = new \JsonSchema\Validator;
$validator = new Validator;
$validator->validate($data, (object)['$ref' => 'file:///' . $schemaFile]);

if ($validator->isValid()) {
Expand Down
12 changes: 6 additions & 6 deletions src/Base/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@

final class HttpClient extends Client
{
public const USER_AGENT = 'ImovelWeb HTTP Client';
public const PRODUCTION = 'production';
public const SANDBOX = 'sandbox';
private const CLIENT_URLS = [
const USER_AGENT = 'ImovelWeb HTTP Client';
const PRODUCTION = 'production';
const SANDBOX = 'sandbox';
const CLIENT_URLS = [
self::PRODUCTION => 'http://api-br.open.navent.com/v1/',
self::SANDBOX => 'http://api-br.sandbox.open.navent.com/v1/',
];

/**
* @var string
*/
public string $baseUrl = '/';
public $baseUrl = '/';

/**
* @var array
*/
public array $headers;
public $headers;

/**
* Initialize the HTTP Client used by SDK.
Expand Down
18 changes: 15 additions & 3 deletions tests/Base/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,20 @@

abstract class Base extends TestCase
{
protected ClientInterface $client;
protected Generator $faker;
protected object $service;
/**
* @var ClientInterface
*/
protected $client;

/**
* @var Generator
*/
protected $faker;

/**
* @var object
*/
protected $service;

public function setUp(): void
{
Expand All @@ -28,6 +39,7 @@ public function getClient(array $handlerStack = []): Client
$mock = new MockHandler($handlerStack);

$handler = HandlerStack::create($mock);

$client = new Client(['handler' => $handler]);
$client->baseUrl = '';

Expand Down
1 change: 0 additions & 1 deletion tests/Base/HttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ final class HttpClientTest extends Base
*/
public function constructor()
{

$token = $this->faker->uuid;
$client = new HttpClient($token);

Expand Down

0 comments on commit 0061073

Please sign in to comment.