Skip to content

Commit f726d7b

Browse files
GrahamCampbellm1guelpf
authored andcommitted
Support httplug v2
1 parent dcce2e7 commit f726d7b

File tree

6 files changed

+40
-16
lines changed

6 files changed

+40
-16
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@
2323
"require": {
2424
"php": "^5.6 || ^7.0",
2525
"ext-xml": "*",
26-
"php-http/client-common": "^1.6",
26+
"php-http/client-common": "^1.6 || ^2.0",
2727
"php-http/client-implementation": "^1.0",
2828
"php-http/discovery": "^1.2",
29-
"php-http/httplug": "^1.1",
30-
"php-http/multipart-stream-builder": "^1.0",
29+
"php-http/httplug": "^1.1 || ^2.0",
30+
"php-http/multipart-stream-builder": "^1.1",
3131
"symfony/options-resolver": "^2.6 || ^3.0 || ^4.0"
3232
},
3333
"require-dev": {
3434
"guzzlehttp/psr7": "^1.2",
35-
"php-http/guzzle6-adapter": "^1.0",
36-
"php-http/mock-client": "^1.0",
35+
"php-http/guzzle6-adapter": "^1.0 || ^2.0",
36+
"php-http/mock-client": "^1.2",
3737
"phpunit/phpunit": "^5.7.27 || ^6.5"
3838
},
3939
"autoload": {

lib/Gitlab/HttpClient/Plugin/ApiVersion.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
namespace Gitlab\HttpClient\Plugin;
54

65
use Http\Client\Common\Plugin;
@@ -14,12 +13,14 @@
1413
*/
1514
class ApiVersion implements Plugin
1615
{
16+
use Plugin\VersionBridgePlugin;
17+
1718
private $redirected = false;
1819

1920
/**
2021
* {@inheritdoc}
2122
*/
22-
public function handleRequest(RequestInterface $request, callable $next, callable $first)
23+
public function doHandleRequest(RequestInterface $request, callable $next, callable $first)
2324
{
2425
$uri = $request->getUri();
2526

lib/Gitlab/HttpClient/Plugin/Authentication.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
*/
1515
class Authentication implements Plugin
1616
{
17+
use Plugin\VersionBridgePlugin;
18+
1719
/**
1820
* @var string
1921
*/
@@ -44,7 +46,7 @@ public function __construct($method, $token, $sudo = null)
4446
/**
4547
* {@inheritdoc}
4648
*/
47-
public function handleRequest(RequestInterface $request, callable $next, callable $first)
49+
public function doHandleRequest(RequestInterface $request, callable $next, callable $first)
4850
{
4951
switch ($this->method) {
5052
case Client::AUTH_HTTP_TOKEN:

lib/Gitlab/HttpClient/Plugin/GitlabExceptionThrower.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
*/
1818
class GitlabExceptionThrower implements Plugin
1919
{
20+
use Plugin\VersionBridgePlugin;
21+
2022
/**
2123
* {@inheritdoc}
2224
*/
23-
public function handleRequest(RequestInterface $request, callable $next, callable $first)
25+
public function doHandleRequest(RequestInterface $request, callable $next, callable $first)
2426
{
2527
return $next($request)->then(function (ResponseInterface $response) {
2628
if ($response->getStatusCode() >= 400 && $response->getStatusCode() < 600) {

lib/Gitlab/HttpClient/Plugin/History.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
*/
1515
class History implements Journal
1616
{
17+
use HistoryTrait;
18+
1719
/**
1820
* @var ResponseInterface
1921
*/
@@ -34,11 +36,4 @@ public function addSuccess(RequestInterface $request, ResponseInterface $respons
3436
{
3537
$this->lastResponse = $response;
3638
}
37-
38-
/**
39-
* {@inheritdoc}
40-
*/
41-
public function addFailure(RequestInterface $request, Exception $exception)
42-
{
43-
}
4439
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Gitlab\HttpClient\Plugin;
4+
5+
use Http\Client\Common\HttpMethodsClientInterface;
6+
use Http\Client\Exception;
7+
use Psr\Http\Client\ClientExceptionInterface;
8+
use Psr\Http\Message\RequestInterface;
9+
10+
if (interface_exists(HttpMethodsClientInterface::class)) {
11+
trait HistoryTrait
12+
{
13+
public function addFailure(RequestInterface $request, ClientExceptionInterface $exception)
14+
{
15+
}
16+
}
17+
} else {
18+
trait HistoryTrait
19+
{
20+
public function addFailure(RequestInterface $request, Exception $exception)
21+
{
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)