We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 8b38e08 + 35418ce commit 1a74e06Copy full SHA for 1a74e06
2 files changed
src/Autowire.php
@@ -74,4 +74,25 @@ public function run(): mixed
74
}
75
return $this->class;
76
77
+
78
+ /**
79
+ * Will wire the interface to the expected instance
80
+ *
81
+ * @param array $bindings
82
+ * @return void
83
+ */
84
+ public static function interfaceWiring(array $bindings): void
85
+ {
86
+ Reflection::interfaceFactory(function (string $className) use ($bindings) {
87
+ $instance = $bindings[$className] ?? null;
88
+ if (is_callable($instance)) {
89
+ $instance = $instance();
90
+ }
91
+ if(is_string($instance)) {
92
+ $di = new self($instance);
93
+ $instance = $di->run();
94
95
+ return $instance;
96
+ });
97
98
0 commit comments