21 const CALLABLE_PATTERN =
'!^([^\:]+)\:([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)$!';
51 if (is_callable($toResolve)) {
55 if (!is_string($toResolve)) {
56 $this->assertCallable($toResolve);
60 if (preg_match(self::CALLABLE_PATTERN, $toResolve, $matches)) {
61 $resolved = $this->resolveCallable($matches[1], $matches[2]);
62 $this->assertCallable($resolved);
67 $resolved = $this->resolveCallable($toResolve);
68 $this->assertCallable($resolved);
85 if ($this->container->has($class)) {
86 return [$this->container->get($class), $method];
89 if (!class_exists($class)) {
93 return [
new $class($this->container), $method];
103 if (!is_callable($callable)) {
105 '%s is not resolvable',
106 is_array($callable) || is_object($callable) ? json_encode($callable) : $callable
__construct(ContainerInterface $container)
Describes the interface of a container that exposes methods to read its entries.
assertCallable($callable)
This class resolves a string of the format 'class:method' into a closure that can be dispatched...
Slim Framework (https://slimframework.com)
resolve($toResolve)
Resolve toResolve into a closure so that the router can dispatch.
resolveCallable($class, $method='__invoke')
Check if string is something in the DIC that's callable or is a class name which has an __invoke() me...