示例#1
0
 /**
  * Find and dispatch a route based on the request http method and uri.
  *
  * @param string $method The HTTP method of the request, that should be GET, POST, PUT, PATCH or DELETE.
  * @param string $uri    The URi of request.
  *
  * @return mixed The request response
  */
 public function dispatch($method, $uri)
 {
     if ($route = $this->match($method, $uri)) {
         return $this->strategy->dispatch($route['action'], $route['params']);
     }
     $this->dispatchNotFoundRoute($method, $uri);
 }
示例#2
0
 /**
  * @param string $template
  * @param array $params
  * @return null|string
  */
 public function render($template, array $params = [])
 {
     $result = null;
     foreach ($this->strategies as $strategy) {
         if ($strategy->canRender($template)) {
             $result = $strategy->render($template, $params);
         }
         if (null !== $result) {
             break;
         }
     }
     if (null === $result) {
         $result = $this->fallbackStrategy->render($template, $params);
     }
     return $result;
 }
示例#3
0
 /**
  * @param $string
  *
  * @return mixed
  */
 protected function getTranslation($string)
 {
     return $this->method->getTranslations()->getTranslations()[md5($string)]->getTranslation();
 }
示例#4
0
 public function lose()
 {
     $this->strategy->study(false);
     $this->loseCount++;
     $this->gameCount++;
 }
示例#5
0
 /**
  * Validates given variable against already registered tests referenced by
  * array of their aliases.
  *
  * @param mixed $value
  * @param string[] $tests
  *
  * @return bool
  */
 public function isValid($value, array $tests)
 {
     return $this->strategy->isValid($this->types, $value, $tests);
 }