Completed
Push — master ( c1ed37...714f13 )
by Korotkov
02:06
created

HttpErrors   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 48 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 0
dl 24
loc 50
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A error404() 8 8 1
A error503() 8 8 1
A error500() 8 8 1
redirect() 0 1 ?
twig() 0 1 ?
data() 0 1 ?

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace App\Http\Supports;
4
5
trait HttpErrors
6
{
7
8 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...
9
    {
10
        $this->redirect()->responseCode('404');
11
12
        return $this->twig('errors/404.html.twig', [
13
            'title'  => '404 Page Not Found :: ' . $this->data('title'),
14
        ]);
15
    }
16
17 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...
18
    {
19
        $this->redirect()->responseCode('503');
20
21
        return $this->twig('errors/503.html.twig', [
22
            'title'  => '503 Service Unavailable :: ' . $this->data('title'),
23
        ]);
24
    }
25
26 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...
27
    {
28
        $this->redirect()->responseCode('503');
29
30
        return $this->twig('errors/503.html.twig', [
31
            'title'  => '503 Service Unavailable :: ' . $this->data('title'),
32
        ]);
33
    }
34
35
    /**
36
     * @param null $target
37
     *
38
     * @return mixed
39
     */
40
    public abstract function redirect($target = null);
41
42
    /**
43
     * @param string $template
44
     * @param array  $params
45
     */
46
    public abstract function twig(string $template, array $params = []): void;
47
48
    /**
49
     * @param string $key
50
     *
51
     * @return string|array
52
     */
53
    public abstract function data(string $key = null);
54
}