ErrorReporting   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 70 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 14
loc 20
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A error404() 7 7 1
A error503() 7 7 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
/**
4
 * ErrorReporting
5
 * @copyright Copyright (c) 2011 - 2014 Aleksandr Torosh (http://wezoom.com.ua)
6
 * @author Aleksandr Torosh <[email protected]>
7
 */
8
namespace Application\Mvc\Helper;
9
10
class ErrorReporting extends \Phalcon\Mvc\User\Component
11
{
12
13 View Code Duplication
    public function error404()
14
    {
15
        $response = $this->getDi()->get('response');
0 ignored issues
show
Bug introduced by
The method get cannot be called on $this->getDi() (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
16
        $response->setHeader(404, 'Not Found');
17
        $response->setContent(include __DIR__ . '/../../../Index/views/error/404.phtml');
18
19
    }
20
21 View Code Duplication
    public function error503()
22
    {
23
        $response = $this->getDi()->get('response');
0 ignored issues
show
Bug introduced by
The method get cannot be called on $this->getDi() (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
24
        $response->setHeader(503, 'Service Unavailable');
25
        $response->setContent(include __DIR__ . '/../../../Index/views/error/503.phtml');
26
27
    }
28
29
}
30