Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ env:
matrix:
fast_finish: true
include:
- php: 7.0
dist: xenial
env: deps=low
- php: 7.1
dist: bionic
env: deps=low
- php: 7.2
dist: bionic
- php: 7.3
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ You can sign up for a Clearhaus account at https://www.clearhaus.com/.

## Requirements

* PHP 7.0+
* PHP 7.1+
* [php-http/client-common ^1.3](https://github.com/php-http/client-common)
* [php-http/discovery ^1.0](https://github.com/php-http/discovery)
* [php-http/discovery ^1.6](https://github.com/php-http/discovery)
* [php-http/httplug ^1.0](https://github.com/php-http/httplug)
* [php-http/message-factory ^1.0.2](https://github.com/php-http/message-factory)
* [phpseclib/phpseclib ^2.0](https://github.com/phpseclib/phpseclib)
* [psr/container ^1.0](https://github.com/php-fig/container)
* [psr/http-message ^1.0](https://github.com/php-fig/http-message)

## Installation

Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
}
},
"require": {
"php": "^7.0",
"php": "^7.1",
"php-http/client-common": "^1.3",
"php-http/discovery": "^1.6",
"php-http/httplug": "^1.0",
Expand All @@ -35,9 +35,10 @@
"psr/http-message": "^1.0"
},
"require-dev": {
"phpspec/phpspec": "^4.0 || ^5.0 || ^6.0",
"phpspec/phpspec": "^5.0 || ^6.0",
"phpspec/prophecy": "^1.6.2",
"laminas/laminas-diactoros": "^1.6 || ^2.0"
"guzzlehttp/psr7": "^1.6",
"http-interop/http-factory-guzzle": "^1.0"
},
"suggest": {
"ext-openssl": "Allow to sign requests using RSA signature of the HTTP body."
Expand Down
7 changes: 3 additions & 4 deletions spec/Api/AbstractSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
namespace spec\Clearhaus\Api;

use Clearhaus\Client;
use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Response;
use PhpSpec\ObjectBehavior;
use Laminas\Diactoros\Response;
use Laminas\Diactoros\Stream;

abstract class AbstractSpec extends ObjectBehavior
{
protected function createHttpResponse(array $body) : Response
{
$stream = new Stream('php://memory', 'rw');
$stream->write(json_encode($body, JSON_FORCE_OBJECT));
$stream = Psr7\stream_for(\json_encode($body, JSON_FORCE_OBJECT));
$stream->rewind();

$httpResponse = (new Response())
Expand Down
4 changes: 2 additions & 2 deletions spec/ClientSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function it_is_initializable()

function it_should_enable_signature(Builder $builder)
{
$builder->addPlugin(Argument::type(Plugin::class))->willReturn(null);
$builder->addPlugin(Argument::type(Plugin::class))->shouldBeCalled();

$builder->addPlugin(Argument::type(SignaturePlugin::class))->shouldBeCalled();

Expand All @@ -35,7 +35,7 @@ function it_should_enable_signature(Builder $builder)

function it_should_return_http_client(Builder $builder, HttpMethodsClient $httpMethodsClient)
{
$builder->addPlugin(Argument::type(Plugin::class))->willReturn(null);
$builder->addPlugin(Argument::type(Plugin::class))->shouldBeCalled();

$builder->build()->willReturn($httpMethodsClient);

Expand Down
7 changes: 3 additions & 4 deletions spec/HttpClient/Plugin/ErrorPluginSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
use Clearhaus\Exception\ValidationFailedException;
use Clearhaus\HttpClient\Plugin\ErrorPlugin;
use Exception;
use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Response;
use Http\Promise\FulfilledPromise;
use Http\Promise\Promise;
use Http\Promise\RejectedPromise;
use PhpSpec\ObjectBehavior;
use Psr\Http\Message\RequestInterface;
use Laminas\Diactoros\Response;
use Laminas\Diactoros\Stream;

class ErrorPluginSpec extends ObjectBehavior
{
Expand Down Expand Up @@ -120,8 +120,7 @@ private function createFailedHttpResponse(int $statusCode,int $errorCode, strin

private function createHttpResponse(array $body, int $statusCode = 200) : Response
{
$stream = new Stream('php://memory', 'rw');
$stream->write(json_encode($body, JSON_FORCE_OBJECT));
$stream = Psr7\stream_for(\json_encode($body, JSON_FORCE_OBJECT));
$stream->rewind();

$httpResponse = (new Response())
Expand Down
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(string $apiKey, Builder $builder = null, string $mod
));
}

public function enableSignature()
public function enableSignature(): void
{
$encrypter = new RSA();
$this->builder->addPlugin(new SignaturePlugin($encrypter, $this->apiKey));
Expand Down
4 changes: 2 additions & 2 deletions src/HttpClient/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ public function build() : HttpMethodsClient
return $this->pluginClient;
}

public function addPlugin(Plugin $plugin)
public function addPlugin(Plugin $plugin): void
{
$this->plugins[] = $plugin;
$this->httpClientModified = true;
}

public function removePlugin(string $fqcn)
public function removePlugin(string $fqcn): void
{
foreach ($this->plugins as $index => $plugin) {
if ($plugin instanceof $fqcn) {
Expand Down