Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a way to be forward compatible with version 2.0 (#132)
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Http\Client\Common\Plugin; | ||
|
||
use Psr\Http\Message\RequestInterface; | ||
|
||
/** | ||
* A plugin that helps you migrate from php-http/client-common 1.x to 2.x. This | ||
* will also help you to support PHP5 at the same time you support 2.x. | ||
* | ||
* @author Tobias Nyholm <tobias.nyholm@gmail.com> | ||
*/ | ||
trait VersionBridgePlugin | ||
{ | ||
abstract protected function doHandleRequest(RequestInterface $request, callable $next, callable $first); | ||
|
||
public function handleRequest(RequestInterface $request, callable $next, callable $first) | ||
{ | ||
return $this->doHandleRequest($request, $next, $first); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Http\Client\Common; | ||
|
||
use Psr\Http\Message\RequestInterface; | ||
|
||
/** | ||
* A client that helps you migrate from php-http/httplug 1.x to 2.x. This | ||
* will also help you to support PHP5 at the same time you support 2.x. | ||
* | ||
* @author Tobias Nyholm <tobias.nyholm@gmail.com> | ||
*/ | ||
trait VersionBridgeClient | ||
{ | ||
abstract protected function doSendRequest(RequestInterface $request); | ||
|
||
public function sendRequest(RequestInterface $request) | ||
{ | ||
return $this->doSendRequest($request); | ||
} | ||
} |