Total Complexity | 9 |
Total Lines | 61 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | trait HttpErrors |
||
8 | { |
||
9 | public function handle404($data, string $type = 'db', array $page = []) |
||
10 | { |
||
11 | if ($type == 'db') { |
||
12 | if (count($data) < 1 || !$data) { |
||
13 | throw new RouterException('404'); |
||
14 | } |
||
15 | } elseif ($type == 'pagination') { |
||
16 | if ($page['id'] > count($data)) { |
||
17 | throw new RouterException('404'); |
||
18 | } |
||
19 | } |
||
20 | } |
||
21 | |||
22 | public function error404() |
||
23 | { |
||
24 | $this->redirect()->responseCode('404'); |
||
25 | |||
26 | return $this->twig('errors/404.html.twig', [ |
||
|
|||
27 | 'title' => '404 Page Not Found :: ' . $this->data('title'), |
||
28 | ]); |
||
29 | } |
||
30 | |||
31 | public function error503() |
||
32 | { |
||
33 | $this->redirect()->responseCode('503'); |
||
34 | |||
35 | return $this->twig('errors/503.html.twig', [ |
||
36 | 'title' => '503 Service Unavailable :: ' . $this->data('title'), |
||
37 | ]); |
||
38 | } |
||
39 | |||
40 | public function error500() |
||
46 | ]); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * @param null $target |
||
51 | * |
||
52 | * @return mixed |
||
53 | */ |
||
54 | public abstract function redirect($target = null); |
||
55 | |||
56 | /** |
||
57 | * @param string $template |
||
58 | * @param array $params |
||
59 | */ |
||
60 | public abstract function twig(string $template, array $params = []): void; |
||
61 | |||
62 | /** |
||
63 | * @param string $key |
||
64 | * |
||
65 | * @return string|array |
||
66 | */ |
||
67 | public abstract function data(string $key = null); |
||
68 | } |
||
69 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.