Exemplo n.º 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);
 }
Exemplo n.º 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;
 }
Exemplo n.º 3
0
 /**
  * @param $string
  *
  * @return mixed
  */
 protected function getTranslation($string)
 {
     return $this->method->getTranslations()->getTranslations()[md5($string)]->getTranslation();
 }
Exemplo n.º 4
0
 public function lose()
 {
     $this->strategy->study(false);
     $this->loseCount++;
     $this->gameCount++;
 }
Exemplo n.º 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);
 }