Skip to content

Commit

Permalink
add support for injecting custom handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
johanrosenson committed Feb 10, 2021
1 parent fe59baa commit 67c50f9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/UtmParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ public static function fake() : UtmParametersInterface
*/
private static function getRequestHandler($request) : RequestHandlerInterface
{
if ($request instanceof RequestHandlerInterface) {
return $request;
}

foreach (self::$requestHandlers as $interface => $handler) {
if ($request instanceof $interface) {
return new $handler;
Expand All @@ -136,6 +140,10 @@ private static function getRequestHandler($request) : RequestHandlerInterface
*/
private function getResponseHandler($response) : ResponseHandlerInterface
{
if ($response instanceof ResponseHandlerInterface) {
return $response;
}

foreach ($this->responseHandlers as $interface => $handler) {
if ($response instanceof $interface) {
return new $handler;
Expand Down

0 comments on commit 67c50f9

Please sign in to comment.