Skip to content

Commit 7c71ff0

Browse files
committed
update depends
1 parent 105a6d3 commit 7c71ff0

File tree

6 files changed

+19
-34
lines changed

6 files changed

+19
-34
lines changed

.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,23 +12,23 @@ Redirect 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-redirect:^1.0
15+
composer require webclient/ext-redirect:^2.0
1616
```
1717

1818
# Using
1919

2020
```php
2121
<?php
2222

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

2727
/**
2828
* @var ClientInterface $client Your PSR-18 HTTP Client
2929
* @var int $maxRedirects Max follow redirects
3030
*/
31-
$http = new Client($client, $maxRedirects);
31+
$http = new RedirectClientDecorator($client, $maxRedirects);
3232

3333
/** @var RequestInterface $request */
3434
$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"

src/Client.php renamed to src/RedirectClientDecorator.php

+4-17
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,15 @@
88
use Psr\Http\Message\RequestInterface;
99
use Psr\Http\Message\ResponseInterface;
1010

11-
use function array_key_exists;
12-
use function array_replace;
13-
use function in_array;
14-
use function parse_url;
15-
16-
final class Client implements ClientInterface
11+
final class RedirectClientDecorator implements ClientInterface
1712
{
18-
19-
/**
20-
* @var ClientInterface
21-
*/
22-
private $client;
23-
24-
/**
25-
* @var int
26-
*/
27-
private $maxRedirects;
13+
private ClientInterface $client;
14+
private int $maxRedirects;
2815

2916
public function __construct(ClientInterface $client, int $maxRedirects = 10)
3017
{
3118
$this->client = $client;
32-
$this->maxRedirects = $maxRedirects > 0 ? $maxRedirects : 0;
19+
$this->maxRedirects = max($maxRedirects, 0);
3320
}
3421

3522
/**

stuff/Handler.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44

55
namespace Stuff\Webclient\Extension\Redirect;
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
* @param ServerRequestInterface $request
1716
* @return ResponseInterface

tests/RedirectClientTest.php renamed to tests/RedirectClientDecoratorTest.php

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

55
namespace Tests\Webclient\Extension\Redirect;
66

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

14-
class RedirectClientTest extends TestCase
14+
class RedirectClientDecoratorTest extends TestCase
1515
{
16-
1716
/**
1817
* @param int $maxRedirects
1918
* @param int $needRedirects
@@ -26,7 +25,7 @@ class RedirectClientTest extends TestCase
2625
public function testRedirects(int $maxRedirects, int $needRedirects, int $expectRedirects)
2726
{
2827

29-
$client = new Client(new FakeClient(new Handler()), $maxRedirects);
28+
$client = new RedirectClientDecorator(new FakeHttpClient(new Handler()), $maxRedirects);
3029

3130
$request = new Request('GET', 'http://localhost/?redirects=' . $needRedirects, ['Accept' => 'text/plain']);
3231

0 commit comments

Comments
 (0)