Completed
Push — master ( d056fc...eab060 )
by Korotkov
05:25
created

HttpErrors::error503()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace App\Web\Supports;
4
5
use Rudra\RouterException;
6
7
trait HttpErrors
8
{
9
10
    public function handle404($data, string $type = 'db', array $page = [])
11
    {
12
        if ($type == 'db') {
13
            if (count($data) < 1 || !$data) {
14
                throw new RouterException('404');
15
            }
16
        } elseif ($type == 'pagination') {
17
            if ($page['id'] > count($data)) {
18
                throw new RouterException('404');
19
            }
20
        }
21
    }
22
23 View Code Duplication
    public function error404()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
    {
25
        $this->redirect()->responseCode('404');
26
27
        return $this->twig('errors/404.html.twig', [
28
            'title' => '404 Page Not Found :: ' . $this->data('title'),
29
        ]);
30
    }
31
32 View Code Duplication
    public function error503()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
    {
34
        $this->redirect()->responseCode('503');
35
36
        return $this->twig('errors/503.html.twig', [
37
            'title' => '503 Service Unavailable :: ' . $this->data('title'),
38
        ]);
39
    }
40
41 View Code Duplication
    public function error500()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
42
    {
43
        $this->redirect()->responseCode('503');
44
45
        return $this->twig('errors/503.html.twig', [
46
            'title' => '503 Service Unavailable :: ' . $this->data('title'),
47
        ]);
48
    }
49
50
    /**
51
     * @param null $target
52
     *
53
     * @return mixed
54
     */
55
    public abstract function redirect($target = null);
56
57
    /**
58
     * @param string $template
59
     * @param array  $params
60
     */
61
    public abstract function twig(string $template, array $params = []): void;
62
63
    /**
64
     * @param string $key
65
     *
66
     * @return string|array
67
     */
68
    public abstract function data(string $key = null);
69
}