Completed
Push — master ( 9efb49...7ad915 )
by Park Jong-Hun
03:23
created

Html::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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