WidgetViewComposer::setWidgetName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
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 6
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
1
<?php namespace Modules\Dashboard\Composers;
2
3
use Illuminate\Contracts\View\View;
4
5
class WidgetViewComposer
6
{
7
    /**
8
     * @var array
9
     */
10
    private $subViews = [];
11
12
    /**
13
     * @param View $view
14
     */
15
    public function compose(View $view)
16
    {
17
        $view->with(['widgets' => $this->subViews]);
18
    }
19
20
    /**
21
     * Add the html of the widget view to the given widget name
22
     * @param string $name
23
     * @param string $view
24
     * @return $this
25
     */
26
    public function addSubview($name, $view)
27
    {
28
        $this->subViews[$name]['html'] = $view;
29
30
        return $this;
31
    }
32
33
    /**
34
     * Add widget options to the given widget name
35
     * @param $name
36
     * @param array $options
37
     * @return $this
38
     */
39
    public function addWidgetOptions($name, array $options)
40
    {
41
        $this->subViews[$name]['options'] = $options;
42
43
        return $this;
44
    }
45
46
    /**
47
     * Set the widget name
48
     * @param string $name
49
     * @return $this
50
     */
51
    public function setWidgetName($name)
52
    {
53
        $this->subViews[$name]['id'] = $name;
54
55
        return $this;
56
    }
57
}
58