Completed
Push — master ( 45c651...8bfbde )
by Damien
02:27
created

DebugExceptionController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handleExceptionAction() 0 20 1
1
<?php
2
/**
3
 * Veto.
4
 * PHP Microframework.
5
 *
6
 * @author Damien Walsh <[email protected]>
7
 * @copyright Damien Walsh 2013-2014
8
 * @version 0.1
9
 * @package veto
10
 */
11
namespace Veto\Debug\Controller;
12
13
use Veto\HTTP\Request;
14
use Veto\HTTP\Response;
15
use Veto\MVC\AbstractController;
16
17
/**
18
 * ExceptionController
19
 *
20
 * This is the debug exception controller that will be called for any exceptions
21
 * from user code that make it to the kernel while the application is in Debug mode.
22
 *
23
 * You can override this by specifying a different class to be used for the
24
 * controller._debug_exception_handler service.
25
 *
26
 * @since 0.3.0
27
 */
28
class DebugExceptionController extends AbstractController
29
{
30
    public function handleExceptionAction(Request $request, \Exception $exception)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31
    {
32
        // The templates for showing exceptions are outside of the normal application
33
        // template path. It is therefore necessary to specify the path here.
34
        $this->get('php_template_engine')->addPath(
35
            __DIR__ . '/../Resources/Exception'
36
        );
37
38
        // Render the template
39
        $response = $this->get('php_template_engine')->render('TextHtml.html.php', array(
40
            'code' => $exception->getCode(),
41
            'file' => $exception->getFile(),
42
            'line' => $exception->getLine(),
43
            'trace' => $exception->getTrace(),
44
            'message' => $exception->getMessage(),
45
            'type' => get_class($exception)
46
        ));
47
48
        return new Response($response);
49
    }
50
}
51