@@ -8,21 +8,21 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class CallableResolver implements StrategyAwareInterface |
| 10 | 10 | { |
| 11 | - use StrategyAwareTrait; |
|
| 11 | + use StrategyAwareTrait; |
|
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * CallableResolver constructor. |
|
| 13 | + /** |
|
| 14 | + * CallableResolver constructor. |
|
| 15 | 15 | */ |
| 16 | - public function __construct() |
|
| 17 | - { |
|
| 18 | - $this->setStrategy(new DefaultCallableStrategy()); |
|
| 19 | - } |
|
| 16 | + public function __construct() |
|
| 17 | + { |
|
| 18 | + $this->setStrategy(new DefaultCallableStrategy()); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @param string $in |
|
| 23 | - * @return mixed |
|
| 21 | + /** |
|
| 22 | + * @param string $in |
|
| 23 | + * @return mixed |
|
| 24 | 24 | */ |
| 25 | - public function resolve($in) { |
|
| 25 | + public function resolve($in) { |
|
| 26 | 26 | return $this->getStrategy()->resolve($in); |
| 27 | - } |
|
| 27 | + } |
|
| 28 | 28 | } |
| 29 | 29 | \ No newline at end of file |
@@ -8,51 +8,51 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class DefaultCallableStrategy implements ResolvableInterface |
| 10 | 10 | { |
| 11 | - const DEFAULT_NAMESPACE_SEPARATOR = '\\'; |
|
| 12 | - const DEFAULT_METHOD_SEPARATOR = '::'; |
|
| 11 | + const DEFAULT_NAMESPACE_SEPARATOR = '\\'; |
|
| 12 | + const DEFAULT_METHOD_SEPARATOR = '::'; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * @var null|string |
|
| 14 | + /** |
|
| 15 | + * @var null|string |
|
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | - private $namespace_separator; |
|
| 19 | - /** |
|
| 20 | - * @var null|string |
|
| 18 | + private $namespace_separator; |
|
| 19 | + /** |
|
| 20 | + * @var null|string |
|
| 21 | 21 | */ |
| 22 | - private $method_separator; |
|
| 22 | + private $method_separator; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * DefaultCallableStrategy constructor. |
|
| 26 | - * @param string $namespace_separator |
|
| 27 | - * @param string $method_separator |
|
| 24 | + /** |
|
| 25 | + * DefaultCallableStrategy constructor. |
|
| 26 | + * @param string $namespace_separator |
|
| 27 | + * @param string $method_separator |
|
| 28 | 28 | */ |
| 29 | - public function __construct($namespace_separator = null, $method_separator = null) { |
|
| 30 | - $this->namespace_separator = ($namespace_separator === null) ? self::DEFAULT_NAMESPACE_SEPARATOR : $namespace_separator; |
|
| 31 | - $this->method_separator = ($method_separator === null) ? self::DEFAULT_METHOD_SEPARATOR : $method_separator; |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @param string $in |
|
| 36 | - * @return array |
|
| 37 | - * @throws \Exception |
|
| 29 | + public function __construct($namespace_separator = null, $method_separator = null) { |
|
| 30 | + $this->namespace_separator = ($namespace_separator === null) ? self::DEFAULT_NAMESPACE_SEPARATOR : $namespace_separator; |
|
| 31 | + $this->method_separator = ($method_separator === null) ? self::DEFAULT_METHOD_SEPARATOR : $method_separator; |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @param string $in |
|
| 36 | + * @return array |
|
| 37 | + * @throws \Exception |
|
| 38 | 38 | */ |
| 39 | - public function resolve($in) |
|
| 40 | - { |
|
| 41 | - $pos = strrpos($in, $this->method_separator); |
|
| 42 | - if ($pos === false) { |
|
| 43 | - throw new \Exception(sprintf('Method separator not found in %s', $in)); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - if ($pos === 0) { |
|
| 47 | - // Use backtrace to find the calling Class |
|
| 48 | - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3); |
|
| 49 | - $class = $trace[2]['class']; |
|
| 50 | - $method = substr($in, $pos + strlen($this->method_separator)); |
|
| 51 | - } else { |
|
| 52 | - $class = substr($in, 0, $pos); |
|
| 53 | - $method = substr($in, $pos + strlen($this->method_separator)); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - return [$class, $method]; |
|
| 57 | - } |
|
| 39 | + public function resolve($in) |
|
| 40 | + { |
|
| 41 | + $pos = strrpos($in, $this->method_separator); |
|
| 42 | + if ($pos === false) { |
|
| 43 | + throw new \Exception(sprintf('Method separator not found in %s', $in)); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + if ($pos === 0) { |
|
| 47 | + // Use backtrace to find the calling Class |
|
| 48 | + $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3); |
|
| 49 | + $class = $trace[2]['class']; |
|
| 50 | + $method = substr($in, $pos + strlen($this->method_separator)); |
|
| 51 | + } else { |
|
| 52 | + $class = substr($in, 0, $pos); |
|
| 53 | + $method = substr($in, $pos + strlen($this->method_separator)); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + return [$class, $method]; |
|
| 57 | + } |
|
| 58 | 58 | } |
| 59 | 59 | \ No newline at end of file |