Example #1
0
 /**
  * Attempts to resolve through the container or fallback on CallableResolver
  *
  * @param mixed $value
  */
 public function resolve($value, $default = 'value')
 {
     $callable = $this->getCallable($value);
     if (is_array($callable)) {
         if (is_callable($callable[0])) {
             return call_user_func_array($callable[0], $callable[1]);
         } else {
             return $callable[0];
         }
     }
     return $this->fallback->resolve($value, $default);
 }
Example #2
0
 /**
  * Attempts to resolve through defined filters
  *
  * @param mixed $value
  */
 public function resolve($value, $default = 'value')
 {
     $matches = [];
     if (is_string($value) && preg_match('/^(' . self::KEY_REGEX . ')' . preg_quote($this->separator) . '(.*)/', $value, $matches)) {
         if (isset($this->filters[$matches[1]])) {
             return call_user_func_array($this->filters[$matches[1]], [$matches[2]]);
         } else {
             if (function_exists($matches[1])) {
                 return call_user_func_array($matches[1], [$matches[2]]);
             }
         }
     }
     return $this->fallback->resolve($value, $default);
 }