Completed
Push — master ( 2a6148...c1b249 )
by Park Jong-Hun
03:18
created

Html::report()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace App\ErrorReporter;
4
5
use Core\ErrorReporter;
6
use \Exception;
7
8
class Html implements ErrorReporter
9
{
10
    /**
11
         * @var View
12
         */
13
    private $view;
14
15
    public function init($setting = [])
16
    {
17
        $this->buildView($setting);
18
    }
19
20
    private function buildView($setting)
21
    {
22
        $this->view = new $setting['view'];
23
        $this->view->init($setting);
24
        $this->view->file($setting['file']);
25
    }
26
27
    public function report(Exception $exception)
28
    {
29
        $this->setReportVariables($exception);
30
        echo $this->view->render();
31
    }
32
33
    private function setReportVariables(Exception $exception)
34
    {
35
        $this->view->set('message', $exception->getMessage());
36
        $this->view->set('file', $exception->getFile());
37
        $this->view->set('line', $exception->getLine());
38
        $this->view->set('traces', $exception->getTrace());
39
    }
40
}
41