ViewException   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 43
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setViewData() 0 4 1
A getViewData() 0 4 1
A setView() 0 4 1
A dumpViewData() 0 4 1
A context() 0 14 2
1
<?php
2
3
namespace Facade\Ignition\Exceptions;
4
5
use ErrorException;
6
use Facade\FlareClient\Contracts\ProvidesFlareContext;
7
use Facade\Ignition\DumpRecorder\HtmlDumper;
8
9
class ViewException extends ErrorException implements ProvidesFlareContext
10
{
11
    /** @var array */
12
    protected $viewData = [];
13
14
    /** @var string */
15
    protected $view = '';
16
17
    public function setViewData(array $data)
18
    {
19
        $this->viewData = $data;
20
    }
21
22
    public function getViewData(): array
23
    {
24
        return $this->viewData;
25
    }
26
27
    public function setView(string $path)
28
    {
29
        $this->view = $path;
30
    }
31
32
    protected function dumpViewData($variable): string
33
    {
34
        return (new HtmlDumper())->dumpVariable($variable);
35
    }
36
37
    public function context(): array
38
    {
39
        $context = [
40
            'view' => [
41
                'view' => $this->view,
42
            ],
43
        ];
44
45
        if (config('flare.reporting.report_view_data')) {
46
            $context['view']['data'] = array_map([$this, 'dumpViewData'], $this->viewData);
47
        }
48
49
        return $context;
50
    }
51
}
52