Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #101 from ste93cry/feature/allow-httplug-2
Browse files Browse the repository at this point in the history
Update dependencies to allow both HTTPlug 1.x and 2.x
  • Loading branch information
mavimo committed Feb 25, 2019
2 parents 0489970 + cf5f94a commit 65f2073
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 34 deletions.
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ php:
- nightly

env:
- dependencies=lowest
- dependencies=highest
- dependencies=lowest

matrix:
fast_finish: true
Expand All @@ -29,8 +29,10 @@ jobs:
- stage: Code style & static analysis
name: PHP CS Fixer
script: composer phpcs
- script: composer phpstan
name: PHPStan
env: dependencies=highest
- name: PHPStan
script: composer phpstan
env: dependencies=highest
- stage: Code coverage
php: 7.3
env: dependencies=highest
Expand Down
21 changes: 8 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "loopline-systems/closeio-api-wrapper",
"description": "A PHP wrapper for the Close.io Api",
"license": "MIT",
"keywords": ["closeio php wrapper"],
"keywords": ["closeio", "close.io", "php", "api", "rest-api"],
"authors": [
{
"name": "Michael Devery",
Expand All @@ -18,28 +18,23 @@
}
],
"require": {
"php": ">=7.1.0",
"php": "^7.1",
"ext-json": "*",
"doctrine/inflector": "^1.3.0",
"doctrine/inflector": "^1.3",
"fig/http-message-util": "^1.1",
"php-http/client-common": "^1.7",
"php-http/client-common": "^1.5|^2.0",
"php-http/client-implementation": "^1.0",
"php-http/discovery": "^1.4",
"php-http/httplug": "^1.1",
"php-http/discovery": "^1.6",
"php-http/httplug": "^1.1|^2.0",
"psr/http-message-implementation": "^1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.13",
"php-coveralls/php-coveralls": "^2.0",
"php-http/curl-client": "^1.7",
"php-http/message": "^1.7",
"php-http/mock-client": "^1.1",
"phpstan/phpstan": "^0.10.3",
"phpunit/phpunit": "^7.3.1",
"psr/http-message-implementation": "^1.0",
"symfony/options-resolver": "^3.0|^4.0",
"symfony/phpunit-bridge": "^4.1",
"webmozart/assert": "^1.3"
"phpunit/phpunit": "^7.3",
"symfony/phpunit-bridge": "^4.1"
},
"autoload": {
"psr-4": {
Expand Down
24 changes: 12 additions & 12 deletions src/LooplineSystems/CloseIoApiWrapper/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
use Http\Discovery\MessageFactoryDiscovery;
use Http\Discovery\UriFactoryDiscovery;
use Http\Message\Authentication\BasicAuth;
use Http\Message\MessageFactory;
use Http\Message\UriFactory;
use Http\Message\RequestFactory as RequestFactoryInterface;
use Http\Message\UriFactory as UriFactoryInterface;
use LooplineSystems\CloseIoApiWrapper\Exception\CloseIoException;
use LooplineSystems\CloseIoApiWrapper\Exception\CloseIoResponseException;

Expand Down Expand Up @@ -58,28 +58,28 @@ final class Client implements ClientInterface
private $httpClient;

/**
* @var UriFactory The URI factory
* @var UriFactoryInterface The URI factory
*/
private $uriFactory;

/**
* @var MessageFactory The factory of PSR-7 requests
* @var RequestFactoryInterface The factory of PSR-7 requests
*/
private $messageFactory;
private $requestFactory;

/**
* Constructor.
*
* @param Configuration $configuration The configuration of the client
* @param HttpClientInterface|null $httpClient The HTTP client
* @param UriFactory|null $uriFactory The URI factory
* @param MessageFactory|null $messageFactory The factory of PSR-7 requests
* @param Configuration $configuration The configuration of the client
* @param HttpClientInterface|null $httpClient The HTTP client
* @param UriFactoryInterface|null $uriFactory The URI factory
* @param RequestFactoryInterface|null $requestFactory The factory of PSR-7 requests
*/
public function __construct(Configuration $configuration, ?HttpClientInterface $httpClient = null, ?UriFactory $uriFactory = null, ?MessageFactory $messageFactory = null)
public function __construct(Configuration $configuration, ?HttpClientInterface $httpClient = null, ?UriFactoryInterface $uriFactory = null, ?RequestFactoryInterface $requestFactory = null)
{
$this->configuration = $configuration;
$this->uriFactory = $uriFactory ?: UriFactoryDiscovery::find();
$this->messageFactory = $messageFactory ?: MessageFactoryDiscovery::find();
$this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find();
$this->httpClient = $this->createHttpClientInstance($httpClient ?: HttpClientDiscovery::find());
}

Expand Down Expand Up @@ -150,7 +150,7 @@ public function sendRequest(CloseIoRequest $request): CloseIoResponse
$requestBody = json_encode($params);
}

$rawRequest = $this->messageFactory->createRequest($request->getMethod(), $request->getUrl(), [], $requestBody);
$rawRequest = $this->requestFactory->createRequest($request->getMethod(), $request->getUrl(), [], $requestBody);

try {
$rawResponse = $this->httpClient->sendRequest($rawRequest);
Expand Down
6 changes: 3 additions & 3 deletions src/LooplineSystems/CloseIoApiWrapper/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace LooplineSystems\CloseIoApiWrapper;

use Http\Client\HttpClient;
use Http\Client\HttpClient as HttpClientInterface;
use LooplineSystems\CloseIoApiWrapper\Exception\CloseIoException;
use LooplineSystems\CloseIoApiWrapper\Exception\CloseIoResponseException;
use LooplineSystems\CloseIoApiWrapper\Exception\JsonException;
Expand All @@ -36,9 +36,9 @@ public function getConfiguration(): Configuration;
/**
* Gets the HTTP client, configured to authenticate with the server.
*
* @return HttpClient
* @return HttpClientInterface
*/
public function getHttpClient(): HttpClient;
public function getHttpClient(): HttpClientInterface;

/**
* Sends a GET request to Close.io REST API and returns the result.
Expand Down
6 changes: 3 additions & 3 deletions src/LooplineSystems/CloseIoApiWrapper/CloseIoResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CloseIoResponse
protected $httpStatusCode;

/**
* @var null|string The body response
* @var string|null The body response
*/
protected $body;

Expand All @@ -52,7 +52,7 @@ class CloseIoResponse
*
* @param CloseIoRequest $request The original request that returned this response
* @param int $httpStatusCode The status code of this response
* @param null|string $body The body response
* @param string|null $body The body response
* @param array $headers The returned HTTP headers
*
* @throws JsonException If the response body failed to be decoded as JSON
Expand Down Expand Up @@ -90,7 +90,7 @@ public function getHttpStatusCode(): int
/**
* Gets the body content returned by this response.
*
* @return null|string
* @return string|null
*/
public function getBody(): ?string
{
Expand Down

0 comments on commit 65f2073

Please sign in to comment.