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