Skip to content

Commit

Permalink
Added a way to be forward compatible with version 2.0 (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyholm authored and dbu committed Dec 29, 2018
1 parent efe327f commit dc9a9eb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Plugin/VersionBridgePlugin.php
@@ -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);
}
}
21 changes: 21 additions & 0 deletions src/VersionBridgeClient.php
@@ -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);
}
}

0 comments on commit dc9a9eb

Please sign in to comment.