From 67c50f944afdb01a57562fc6782ba4c293dd015d Mon Sep 17 00:00:00 2001 From: Johan Date: Wed, 10 Feb 2021 13:25:56 +0700 Subject: [PATCH] add support for injecting custom handlers --- src/UtmParameters.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/UtmParameters.php b/src/UtmParameters.php index 868673d..a25d210 100644 --- a/src/UtmParameters.php +++ b/src/UtmParameters.php @@ -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; @@ -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;