| Total Complexity | 8 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class HttpException extends Exception { |
||
| 12 | |||
| 13 | protected static $controller = 'errors'; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @param int $code |
||
| 17 | * @param string $message |
||
| 18 | */ |
||
| 19 | public function __construct($code, $message = '') { |
||
| 21 | } |
||
| 22 | |||
| 23 | /** Executa uma resposta HTTP de erro */ |
||
| 24 | public function run() { |
||
| 25 | $app = Application::app(); |
||
| 26 | $app->setPage($this->code); |
||
| 27 | $app->view = new View($this->code, ['exception' => $this]); |
||
| 28 | $controller = ControllerFactory::create(static::$controller, '_' . $this->code); |
||
| 29 | |||
| 30 | if (get_class($controller) !== get_class($app->controller)) { |
||
| 31 | $app->controller = $controller; |
||
| 32 | } |
||
| 33 | |||
| 34 | http_response_code($this->code); |
||
| 35 | $this->retry(); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** Define 404 caso definiu um erro inválido */ |
||
| 39 | protected function retry() { |
||
| 45 | } |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | /** @return boolean */ |
||
| 50 | private function is404() { |
||
| 52 | } |
||
| 53 | |||
| 54 | /** @return boolean */ |
||
| 55 | public static function isErrorCode($code) { |
||
| 60 |