Skip to content

Commit 8a4bb93

Browse files
committed
rename Client to ProtocolClientDecorator
1 parent 8d62fd0 commit 8a4bb93

8 files changed

+21
-28
lines changed

.github/FUNDING.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
custom: "https://www.paypal.me/ddrv"
1+
custom: "https://www.paypal.me/ddrv"
2+
patreon: ddrv

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88

99
strategy:
1010
matrix:
11-
php: [7.0, 7.1, 7.2, 7.3, 7.4, 8.0]
11+
php: [7.4, 8.0, 8.1]
1212

1313
steps:
1414
- name: Checkout code

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ Auto change protocol version extension for PSR-18 HTTP client.
1212
Install this package and your favorite [psr-18 implementation](https://packagist.org/providers/psr/http-client-implementation).
1313

1414
```bash
15-
composer require webclient/ext-protocol-version:^1.0
15+
composer require webclient/ext-protocol-version:^2.0
1616
```
1717

1818
# Using
1919

2020
```php
2121
<?php
2222

23-
use Webclient\Extension\ProtocolVersion\Client;
23+
use Webclient\Extension\ProtocolVersion\ProtocolClientDecorator;
2424
use Psr\Http\Client\ClientInterface;
2525
use Psr\Http\Message\RequestInterface;
2626

2727
/**
2828
* @var ClientInterface $client Your PSR-18 HTTP Client
2929
*/
30-
$http = new Client($client);
30+
$http = new ProtocolClientDecorator($client);
3131

3232
/** @var RequestInterface $request */
3333
$response = $http->sendRequest($request);

composer.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
}
1313
],
1414
"require": {
15-
"php": ">=7.0",
15+
"php": "^7.4 || ^8.0",
1616
"psr/http-client": "^1.0"
1717
},
1818
"require-dev": {
19-
"guzzlehttp/psr7": "^1.7",
20-
"phpunit/phpunit": ">=6.5",
21-
"squizlabs/php_codesniffer": "^3.5",
22-
"webclient/fake-http-client": "^1.0"
19+
"nyholm/psr7": "^1.5",
20+
"phpunit/phpunit": "^6.5 || ^7.5 || ^8.5 || ^9.5",
21+
"squizlabs/php_codesniffer": "^3.7",
22+
"webclient/fake-http-client": "^2.0"
2323
},
2424
"provide": {
2525
"psr/http-client-implementation": "1.0"

phpcs.xml.dist

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
<arg name="colors"/>
99

1010
<!-- inherit rules from: -->
11-
<rule ref="PSR12">
12-
<exclude name="PSR12.Properties.ConstantVisibility.NotFound"/>
13-
</rule>
11+
<rule ref="PSR12"/>
1412

1513
<!-- Paths to check -->
1614
<file>src</file>

src/Client.php src/ProtocolClientDecorator.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@
88
use Psr\Http\Message\RequestInterface;
99
use Psr\Http\Message\ResponseInterface;
1010

11-
final class Client implements ClientInterface
11+
final class ProtocolClientDecorator implements ClientInterface
1212
{
13-
14-
/**
15-
* @var ClientInterface
16-
*/
17-
private $client;
13+
private ClientInterface $client;
1814

1915
public function __construct(ClientInterface $client)
2016
{

stuff/Handler.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44

55
namespace Stuff\Webclient\Extension\ProtocolVersion;
66

7-
use GuzzleHttp\Psr7\Response;
7+
use Nyholm\Psr7\Response;
88
use Psr\Http\Message\ResponseInterface;
99
use Psr\Http\Message\ServerRequestInterface;
1010
use Psr\Http\Server\RequestHandlerInterface;
1111

1212
class Handler implements RequestHandlerInterface
1313
{
14-
1514
/**
1615
* @var string[]
1716
*/
18-
private $versions;
17+
private array $versions;
1918

2019
public function __construct(string $defaultVersion, string ...$supportedVersions)
2120
{

tests/ClientTest.php tests/ProtocolClientDecoratorTest.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44

55
namespace Tests\Webclient\Extension\ProtocolVersion;
66

7+
use Nyholm\Psr7\Request;
78
use Stuff\Webclient\Extension\ProtocolVersion\Handler;
8-
use GuzzleHttp\Psr7\Request;
99
use PHPUnit\Framework\TestCase;
1010
use Psr\Http\Client\ClientExceptionInterface;
11-
use Webclient\Extension\ProtocolVersion\Client;
12-
use Webclient\Fake\Client as FakeClient;
11+
use Webclient\Extension\ProtocolVersion\ProtocolClientDecorator;
12+
use Webclient\Fake\FakeHttpClient;
1313

14-
class ClientTest extends TestCase
14+
class ProtocolClientDecoratorTest extends TestCase
1515
{
16-
1716
/**
1817
* @param string $requestVersion
1918
* @param string $responseVersion
@@ -25,7 +24,7 @@ class ClientTest extends TestCase
2524
*/
2625
public function testProtocol(string $requestVersion, string $responseVersion, array $supportedVersions)
2726
{
28-
$client = new Client(new FakeClient(new Handler(...$supportedVersions)));
27+
$client = new ProtocolClientDecorator(new FakeHttpClient(new Handler(...$supportedVersions)));
2928
$request = new Request('GET', '/', ['Accept' => 'text/plain'], null, $requestVersion);
3029
$response = $client->sendRequest($request);
3130
$this->assertSame($responseVersion, $response->getProtocolVersion());

0 commit comments

Comments
 (0)