diff options
| author | Sam Light <sam@lightscale.co.uk> | 2026-06-10 21:37:20 +0100 |
|---|---|---|
| committer | Sam Light <sam@lightscale.co.uk> | 2026-06-10 21:37:20 +0100 |
| commit | b2aaaa8fa04f690fed598c31b65a6405b565c303 (patch) | |
| tree | 9fce597275fbf22e0aa33784a6706a7ad878f9bb /src/Concerns/Strategy/RunsRoute.php | |
| parent | d2a3da17cea4e172949ceac033e2455be0466b94 (diff) | |
Diffstat (limited to 'src/Concerns/Strategy/RunsRoute.php')
| -rw-r--r-- | src/Concerns/Strategy/RunsRoute.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Concerns/Strategy/RunsRoute.php b/src/Concerns/Strategy/RunsRoute.php new file mode 100644 index 0000000..849ae80 --- /dev/null +++ b/src/Concerns/Strategy/RunsRoute.php @@ -0,0 +1,23 @@ +<?php + +declare(strict_types=1); + +namespace Lightscale\Router\Concerns\Strategy; + +use Lightscale\Router\Exceptions\InvalidResponseException; +use Lightscale\Router\RouteCall; +use Psr\Http\Message\ResponseInterface; + +trait RunsRoute +{ + public function runRoute(RouteCall $call): ResponseInterface + { + $result = ($call->route->getHandler())($call); + + if ($result instanceof ResponseInterface) { + return $result; + } + + throw new InvalidResponseException(); + } +} |
