aboutsummaryrefslogtreecommitdiff
path: root/tests/Fixtures/FakeResolver.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Fixtures/FakeResolver.php')
-rw-r--r--tests/Fixtures/FakeResolver.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/Fixtures/FakeResolver.php b/tests/Fixtures/FakeResolver.php
new file mode 100644
index 0000000..af6ec1f
--- /dev/null
+++ b/tests/Fixtures/FakeResolver.php
@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace BrettParson\MiniRoute\Tests\Fixtures;
+
+use BrettParson\MiniRoute\Controller\ControllerResolverInterface;
+use RuntimeException;
+
+final class FakeResolver implements ControllerResolverInterface
+{
+ /** @var array<string, object> */
+ private array $bindings = [];
+
+ public function bind(string $class, object $instance): void
+ {
+ $this->bindings[$class] = $instance;
+ }
+
+ public function resolve(string $class): object
+ {
+ if (!array_key_exists($class, $this->bindings)) {
+ throw new RuntimeException("No binding for {$class}");
+ }
+
+ return $this->bindings[$class];
+ }
+}