Skip to content

Commit dc9a9eb

Browse files
Nyholmdbu
authored andcommitted
Added a way to be forward compatible with version 2.0 (#132)
1 parent efe327f commit dc9a9eb

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/Plugin/VersionBridgePlugin.php

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Http\Client\Common\Plugin;
4+
5+
use Psr\Http\Message\RequestInterface;
6+
7+
/**
8+
* A plugin that helps you migrate from php-http/client-common 1.x to 2.x. This
9+
* will also help you to support PHP5 at the same time you support 2.x.
10+
*
11+
* @author Tobias Nyholm <[email protected]>
12+
*/
13+
trait VersionBridgePlugin
14+
{
15+
abstract protected function doHandleRequest(RequestInterface $request, callable $next, callable $first);
16+
17+
public function handleRequest(RequestInterface $request, callable $next, callable $first)
18+
{
19+
return $this->doHandleRequest($request, $next, $first);
20+
}
21+
}

src/VersionBridgeClient.php

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Http\Client\Common;
4+
5+
use Psr\Http\Message\RequestInterface;
6+
7+
/**
8+
* A client that helps you migrate from php-http/httplug 1.x to 2.x. This
9+
* will also help you to support PHP5 at the same time you support 2.x.
10+
*
11+
* @author Tobias Nyholm <[email protected]>
12+
*/
13+
trait VersionBridgeClient
14+
{
15+
abstract protected function doSendRequest(RequestInterface $request);
16+
17+
public function sendRequest(RequestInterface $request)
18+
{
19+
return $this->doSendRequest($request);
20+
}
21+
}

0 commit comments

Comments
 (0)