HttpErrorsController   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 9

4 Methods

Rating   Name   Duplication   Size   Complexity  
A handle404() 0 9 6
A error500() 0 6 1
A error404() 0 4 1
A error503() 0 4 1
1
<?php
2
3
namespace App\Ship\Errors\Controller;
4
5
use Rudra\Exceptions\RouterException;
6
use App\Ship\Errors\ErrorsController;
7
8
class HttpErrorsController extends ErrorsController
9
{
10
    /**
11
     * @throws RouterException
12
     */
13
    public function handle404($data, string $type = 'db', array $page = []): void
14
    {
15
        if ($type == 'db') {
16
            if (count($data) < 1 || !$data) {
17
                throw new RouterException('404');
18
            }
19
        } elseif ($type == 'pagination') {
20
            if ($page['id'] > count($data)) {
21
                throw new RouterException('404');
22
            }
23
        }
24
    }
25
26
    public function error404(): void
27
    {
28
        data(["content" => view("errors.404")]);
29
        render("layout", data());
30
    }
31
32
    public function error503(): void
33
    {
34
        data(["content" => view("errors.503")]);
35
        render("layout", data());
36
    }
37
38
    /**
39
     * @deprecated
40
     * @return mixed
41
     */
42
    public function error500()
43
    {
44
        $this->redirect()->responseCode('503');
0 ignored issues
show
Bug introduced by
The method redirect() does not exist on App\Ship\Errors\Controller\HttpErrorsController. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

44
        $this->/** @scrutinizer ignore-call */ 
45
               redirect()->responseCode('503');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
46
        return $this->twig('errors/503.html.twig', [
0 ignored issues
show
Bug introduced by
The method twig() does not exist on App\Ship\Errors\Controller\HttpErrorsController. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
        return $this->/** @scrutinizer ignore-call */ twig('errors/503.html.twig', [

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
            'title' => '503 Service Unavailable :: ' . data('title'),
48
        ]);
49
    }
50
}
51