Illuminate   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 94.74%

Importance

Changes 0
Metric Value
dl 0
loc 75
rs 10
c 0
b 0
f 0
ccs 18
cts 19
cp 0.9474
wmc 8
lcom 1
cbo 3

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A make() 0 10 2
A with() 0 8 2
A render() 0 8 2
A exists() 0 4 1
1
<?php
2
namespace Malezha\Menu\Render;
3
4
use Illuminate\Contracts\Container\Container;
5
use Illuminate\Contracts\View\Factory;
6
use Illuminate\Contracts\View\View;
7
use Malezha\Menu\Contracts\MenuRender;
8
9
/**
10
 * Class Illuminate
11
 * @package Malezha\Menu\Render
12
 */
13
class Illuminate implements MenuRender
14
{
15
    /**
16
     * @var Container
17
     */
18
    protected $container;
19
20
    /**
21
     * @var Factory
22
     */
23
    protected $factory;
24
25
    /**
26
     * @var View
27
     */
28
    protected $view = null;
29
30
    /**
31
     * @inheritDoc
32
     */
33 3
    public function __construct(Container $container)
34
    {
35 3
        $this->container = $container;
36 3
        $this->factory = $this->container->make(Factory::class);
37 3
    }
38
39
    /**
40
     * @inheritDoc
41
     */
42 3
    public function make($view)
43
    {
44 3
        if (!$this->exists($view)) {
45 1
            throw new \Exception('View not found');
46
        }
47
48 2
        $this->view = $this->factory->make($view);
49
50 2
        return $this;
51
    }
52
53
    /**
54
     * @inheritDoc
55
     */
56 2
    public function with($params, $value = null)
57
    {
58 2
        if (!is_null($this->view)) {
59 2
            $this->view->with($params, $value);
60
        }
61
62 2
        return $this;
63
    }
64
65
    /**
66
     * @inheritDoc
67
     */
68 2
    public function render()
69
    {
70 2
        if (!is_null($this->view)) {
71 2
            return $this->view->render();
72
        }
73
74
        return '';
75
    }
76
77
    /**
78
     * Determine if a given view exists.
79
     *
80
     * @param  string  $view
81
     * @return bool
82
     */
83 3
    public function exists($view)
84
    {
85 3
        return $this->factory->exists($view);
86
    }
87
}