Builder::fromArray()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
1
<?php
2
namespace Malezha\Menu\Contracts;
3
4
use Illuminate\Contracts\Container\Container;
5
use Illuminate\Contracts\Support\Arrayable;
6
7
/**
8
 * Interface Builder
9
 * @package Malezha\Menu\Contracts
10
 */
11
interface Builder extends HasAttributes, HasActiveAttributes, Arrayable, \ArrayAccess
12
{
13
    const UL = 'ul';
14
15
    const OL = 'ol';
16
17
    /**
18
     * @param Container $container
19
     * @param Attributes $attributes
20
     * @param Attributes $activeAttributes
21
     * @param string $type
22
     * @param string $view
23
     * @internal param string $name
24
     */
25
    function __construct(Container $container, Attributes $attributes, Attributes $activeAttributes,
26
                         $type = self::UL, $view = null);
27
28
    /**
29
     * @param string $name
30
     * @param string $type
31
     * @param callable|null $callback
32
     * @return ElementFactory|Element
33
     */
34
    public function create($name, $type, callable $callback = null);
35
36
    /**
37
     * Insert values before item
38
     * 
39
     * @param string $name
40
     * @param callable $callback
41
     * @return Element
42
     */
43
    public function insertBefore($name, callable $callback);
44
45
    /**
46
     * Insert values after item
47
     *
48
     * @param string $name
49
     * @param callable $callback
50
     * @return mixed
51
     */
52
    public function insertAfter($name, callable $callback);
53
54
    /**
55
     * Check exits by name
56
     *
57
     * @param string $name
58
     */
59
    public function has($name);
60
61
    /**
62
     * Get element or sub menu by name
63
     *
64
     * @param string $name
65
     * @param mixed|null $default
66
     * @return ElementFactory|Element|mixed
67
     */
68
    public function get($name, $default = null);
69
70
    /**
71
     * Get element or sub menu by index
72
     *
73
     * @param int $index
74
     * @param mixed|null $default
75
     * @return ElementFactory|Element|mixed
76
     */
77
    public function getByIndex($index, $default = null);
78
79
    /**
80
     * Get all elements
81
     *
82
     * @return array
83
     */
84
    public function all();
85
86
    /**
87
     * Delete element
88
     *
89
     * @param string $name
90
     */
91
    public function forget($name);
92
93
    /**
94
     * Get menu type: UL or OL
95
     *
96
     * @return string
97
     */
98
    public function getType();
99
100
    /**
101
     * Set menu type. You can use constants at this interface
102
     *
103
     * @param string $type
104
     */
105
    public function setType($type);
106
107
    /**
108
     * Render menu to html
109
     *
110
     * @param string|null $view
111
     * @return string
112
     */
113
    public function render($view = null);
114
115
    /**
116
     * Get render view
117
     *
118
     * @return string
119
     */
120
    public function getView();
121
122
    /**
123
     * Set render view
124
     *
125
     * @param string $view
126
     * @throws \Exception
127
     */
128
    public function setView($view);
129
130
    /**
131
     * @param array $builder
132
     * @return Builder
133
     */
134
    static public function fromArray(array $builder);
0 ignored issues
show
Coding Style introduced by
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
135
}