Skip to content

Commit

Permalink
Merge pull request #27 from sunrise-php/release/v1.4.1
Browse files Browse the repository at this point in the history
v1.4.1
  • Loading branch information
fenric committed Oct 13, 2021
2 parents e83e412 + afef733 commit c550995
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 76 deletions.
20 changes: 10 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,40 @@ jobs:
steps:
- checkout
- run: php -v
- run: composer install --no-interaction --prefer-source --no-suggest
- run: php vendor/bin/phpunit --colors=always
- run: composer install --no-interaction --no-suggest --prefer-source
- run: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text
php72:
docker:
- image: circleci/php:7.2-cli-node-browsers
steps:
- checkout
- run: php -v
- run: composer install --no-interaction --prefer-source --no-suggest
- run: php vendor/bin/phpunit --colors=always
- run: composer install --no-interaction --no-suggest --prefer-source
- run: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text
php73:
docker:
- image: circleci/php:7.3-cli-node-browsers
steps:
- checkout
- run: php -v
- run: composer install --no-interaction --prefer-source --no-suggest
- run: php vendor/bin/phpunit --colors=always
- run: composer install --no-interaction --no-suggest --prefer-source
- run: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text
php74:
docker:
- image: circleci/php:7.4-cli-node-browsers
steps:
- checkout
- run: php -v
- run: composer install --no-interaction --prefer-source --no-suggest
- run: php vendor/bin/phpunit --colors=always
- run: composer install --no-interaction --no-suggest --prefer-source
- run: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text
php80:
docker:
- image: circleci/php:8.0-cli-node-browsers
steps:
- checkout
- run: php -v
- run: composer install --no-interaction --prefer-source --no-suggest
- run: php vendor/bin/phpunit --colors=always
- run: composer install --no-interaction --no-suggest --prefer-source
- run: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text
workflows:
version: 2
build:
Expand Down
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,5 @@ indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
16 changes: 8 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.php_cs.cache
.phpunit.result.cache
composer.lock
coverage.xml
phpbench.json
phpcs.xml
phpunit.xml
vendor/
/.php_cs.cache
/.phpunit.result.cache
/composer.lock
/coverage.xml
/phpbench.json
/phpcs.xml
/phpunit.xml
/vendor/
5 changes: 4 additions & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
build:
environment:
php:
version: '8.0'
nodes:
analysis:
tests:
Expand All @@ -7,7 +10,7 @@ build:
coverage:
tests:
override:
- command: php vendor/bin/phpunit --coverage-clover coverage.xml
- command: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-clover coverage.xml
coverage:
file: coverage.xml
format: clover
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
## HTTP cURL client for PHP 7.1+ (incl. PHP 8) based on PSR-18
# HTTP cURL client for PHP 7.1+ (incl. PHP 8) based on PSR-18

[![Gitter](https://badges.gitter.im/sunrise-php/support.png)](https://gitter.im/sunrise-php/support)
[![Build Status](https://circleci.com/gh/sunrise-php/http-client-curl.svg?style=shield)](https://circleci.com/gh/sunrise-php/http-client-curl)
[![Code Coverage](https://scrutinizer-ci.com/g/sunrise-php/http-client-curl/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/sunrise-php/http-client-curl/?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/sunrise-php/http-client-curl/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/sunrise-php/http-client-curl/?branch=master)
[![Total Downloads](https://poser.pugx.org/sunrise/http-client-curl/downloads)](https://packagist.org/packages/sunrise/http-client-curl)
[![Latest Stable Version](https://poser.pugx.org/sunrise/http-client-curl/v/stable)](https://packagist.org/packages/sunrise/http-client-curl)
[![License](https://poser.pugx.org/sunrise/http-client-curl/license)](https://packagist.org/packages/sunrise/http-client-curl)
[![Total Downloads](https://poser.pugx.org/sunrise/http-client-curl/downloads?format=flat)](https://packagist.org/packages/sunrise/http-client-curl)
[![Latest Stable Version](https://poser.pugx.org/sunrise/http-client-curl/v/stable?format=flat)](https://packagist.org/packages/sunrise/http-client-curl)
[![License](https://poser.pugx.org/sunrise/http-client-curl/license?format=flat)](https://packagist.org/packages/sunrise/http-client-curl)

---

Expand All @@ -18,7 +17,7 @@ composer require sunrise/http-client-curl

## How to use?

### Sunrise HTTP Factory
### Sunrise

```bash
composer require sunrise/http-factory
Expand All @@ -33,7 +32,7 @@ $client = new Client(new ResponseFactory());
$request = (new RequestFactory)->createRequest('GET', 'http://php.net/');
$response = $client->sendRequest($request);

// just use PSR-7 Response object...
// just use PSR-7 response...
```

### Zend Diactoros
Expand All @@ -51,7 +50,7 @@ $client = new Client(new ResponseFactory());
$request = (new RequestFactory)->createRequest('GET', 'http://php.net/');
$response = $client->sendRequest($request);

// just use PSR-7 Response object...
// just use PSR-7 response...
```

### cURL options
Expand All @@ -70,14 +69,13 @@ $client = new Client(new ResponseFactory(), [
$requests = [
(new RequestFactory)->createRequest('GET', 'http://php.net/'),
(new RequestFactory)->createRequest('GET', 'http://php.net/'),
(new RequestFactory)->createRequest('GET', 'http://php.net/'),
];

$client = new Client(new ResponseFactory());
$responses = $client->sendRequests(...$request);

foreach ($responses as $response) {
// just use PSR-7 Response object...
// just use PSR-7 response...
}
```

Expand Down
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@
},
"scripts": {
"test": [
"phpunit --colors=always --coverage-text",
"phpcs"
"phpcs",
"XDEBUG_MODE=coverage phpunit --coverage-text"
],
"build": [
"phpdoc -d src/ -t phpdoc/",
"XDEBUG_MODE=coverage phpunit --coverage-html coverage/"
]
}
}
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</include>
</coverage>
<testsuites>
<testsuite name="Sunrise HTTP CURL Client Test Suite">
<testsuite name="sunrise.http.curlClient.testSuite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
Expand Down
16 changes: 6 additions & 10 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
use const CURLOPT_URL;

/**
* HTTP Client based on cURL
* HTTP client based on cURL
*
* @link http://php.net/manual/en/intro.curl.php
* @link https://curl.haxx.se/libcurl/c/libcurl-errors.html
Expand All @@ -69,15 +69,11 @@ class Client implements ClientInterface
{

/**
* Response Factory
*
* @var ResponseFactoryInterface
*/
protected $responseFactory;

/**
* cURL options
*
* @var array
*/
protected $curlOptions;
Expand All @@ -97,7 +93,7 @@ public function __construct(
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function sendRequest(RequestInterface $request) : ResponseInterface
{
Expand Down Expand Up @@ -139,7 +135,7 @@ public function sendRequests(RequestInterface ...$requests) : array
}

do {
curl_multi_exec($curlMultiHandle, $active);
curl_multi_exec($curlMultiHandle, $active);
} while ($active);

$responses = [];
Expand All @@ -155,7 +151,7 @@ public function sendRequests(RequestInterface ...$requests) : array
}

/**
* Creates CurlHandle using the given Request
* Creates CurlHandle using the given request
*
* @param RequestInterface $request
*
Expand Down Expand Up @@ -194,7 +190,7 @@ private function createCurlHandleFromRequest(RequestInterface $request)
}

/**
* Creates Response using the given CurlHandle
* Creates response using the given CurlHandle
*
* @param resource $curlHandle
*
Expand Down Expand Up @@ -225,7 +221,7 @@ private function createResponseFromCurlHandle($curlHandle) : ResponseInterface
}

/**
* Fills the given Response with the header fields using the given header
* Fills the given response with the header fields using the given header
*
* @param ResponseInterface $response
* @param string $header
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ClientException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
/**
* Import classes
*/
use RuntimeException;
use Psr\Http\Client\ClientExceptionInterface;
use RuntimeException;

/**
* ClientException
Expand Down
10 changes: 4 additions & 6 deletions src/Exception/NetworkException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
/**
* Import classes
*/
use Throwable;
use Psr\Http\Client\NetworkExceptionInterface;
use Psr\Http\Message\RequestInterface;
use Throwable;

/**
* NetworkException
Expand All @@ -25,8 +25,6 @@ class NetworkException extends ClientException implements NetworkExceptionInterf
{

/**
* Request instance
*
* @var RequestInterface
*/
protected $request;
Expand All @@ -37,21 +35,21 @@ class NetworkException extends ClientException implements NetworkExceptionInterf
* @param RequestInterface $request
* @param string $message
* @param int $code
* @param Throwable $previous
* @param Throwable|null $previous
*/
public function __construct(
RequestInterface $request,
string $message = '',
int $code = 0,
Throwable $previous = null
?Throwable $previous = null
) {
$this->request = $request;

parent::__construct($message, $code, $previous);
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function getRequest() : RequestInterface
{
Expand Down
10 changes: 4 additions & 6 deletions src/Exception/RequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
/**
* Import classes
*/
use Throwable;
use Psr\Http\Client\RequestExceptionInterface;
use Psr\Http\Message\RequestInterface;
use Throwable;

/**
* RequestException
Expand All @@ -25,8 +25,6 @@ class RequestException extends ClientException implements RequestExceptionInterf
{

/**
* Request instance
*
* @var RequestInterface
*/
protected $request;
Expand All @@ -37,21 +35,21 @@ class RequestException extends ClientException implements RequestExceptionInterf
* @param RequestInterface $request
* @param string $message
* @param int $code
* @param Throwable $previous
* @param Throwable|null $previous
*/
public function __construct(
RequestInterface $request,
string $message = '',
int $code = 0,
Throwable $previous = null
?Throwable $previous = null
) {
$this->request = $request;

parent::__construct($message, $code, $previous);
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function getRequest() : RequestInterface
{
Expand Down
2 changes: 2 additions & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Sunrise\Http\Client\Curl\Tests;

use RuntimeException;
Expand Down

0 comments on commit c550995

Please sign in to comment.