ErrorController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 34
ccs 13
cts 13
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A error() 0 6 1
A exception() 0 11 2
1
<?php
2
namespace Nkey\Caribu\Mvc\Controller;
3
4
use Generics\Client\HttpStatus;
5
6
/**
7
 * The error controller
8
 *
9
 * The error controller provides the fallback rendering if some request
10
 * could not be routed correctly.
11
 *
12
 * It will be registered in application as soon as the Application::init()
13
 * function is performed.
14
 *
15
 * @author Maik Greubel <[email protected]>
16
 *
17
 *         This file is part of Caribu MVC package
18
 */
19
class ErrorController extends AbstractController
20
{
21
22
    /**
23
     * Error processing method
24
     *
25
     * @param Request $request
26
     *            The request
27
     */
28 4
    public function error(Request $request)
29
    {
30 4
        $this->response->setCode(404);
31 4
        printf("<h2>%s</h2>", HttpStatus::getStatus(404));
32 4
        printf("Requested document %s on %s could not be found!", $request->getAction(), $request->getController());
33 4
    }
34
35
    /**
36
     * Error processing for exceptions
37
     *
38
     * @param Request $request
39
     *            The request which contains an exception
40
     */
41 1
    public function exception(Request $request)
42
    {
43 1
        $ex = $request->getException();
44
        
45 1
        $this->response->setCode(500);
46 1
        printf("<h2>%s</h2>", HttpStatus::getStatus(500));
47 1
        while ($ex != null) {
48 1
            printf("<h3>%s</h3><pre>%s</pre>", $ex->getMessage(), $ex->getTraceAsString());
49 1
            $ex = $ex->getPrevious();
50
        }
51 1
    }
52
}
53