1 | <?php |
||
16 | class Breadcrumbs implements BreadcrumbsContract |
||
17 | { |
||
18 | /* ----------------------------------------------------------------- |
||
19 | | Constants |
||
20 | | ----------------------------------------------------------------- |
||
21 | */ |
||
22 | |||
23 | const DEFAULT_TEMPLATE = 'bootstrap-4'; |
||
24 | |||
25 | /* ----------------------------------------------------------------- |
||
26 | | Properties |
||
27 | | ----------------------------------------------------------------- |
||
28 | */ |
||
29 | |||
30 | /** |
||
31 | * Default template view. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | private $template; |
||
36 | |||
37 | /** |
||
38 | * Supported template views. |
||
39 | * |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $supported = [ |
||
43 | 'bootstrap-4' => 'breadcrumbs::bootstrap-4', |
||
44 | ]; |
||
45 | |||
46 | /** @var array */ |
||
47 | protected $callbacks = []; |
||
48 | |||
49 | /* ----------------------------------------------------------------- |
||
50 | | Constructor |
||
51 | | ----------------------------------------------------------------- |
||
52 | */ |
||
53 | |||
54 | /** |
||
55 | * Create a Breadcrumbs instance. |
||
56 | * |
||
57 | * @param array $supported |
||
58 | * @param string|null $template |
||
59 | */ |
||
60 | 54 | public function __construct(array $supported, $template = null) |
|
65 | |||
66 | /* ----------------------------------------------------------------- |
||
67 | | Getters & Setters |
||
68 | | ----------------------------------------------------------------- |
||
69 | */ |
||
70 | |||
71 | /** |
||
72 | * Set the supported template. |
||
73 | * |
||
74 | * @param array $supported |
||
75 | * |
||
76 | * @return $this |
||
77 | */ |
||
78 | 54 | public function setSupported(array $supported) |
|
84 | |||
85 | /** |
||
86 | * Set default template view. |
||
87 | * |
||
88 | * @param string $template |
||
89 | * |
||
90 | * @return $this |
||
91 | */ |
||
92 | 54 | public function setTemplate($template) |
|
100 | |||
101 | /** |
||
102 | * Get the template view. |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | 18 | private function getView(): string |
|
110 | |||
111 | /* ----------------------------------------------------------------- |
||
112 | | Main Methods |
||
113 | | ----------------------------------------------------------------- |
||
114 | */ |
||
115 | |||
116 | /** |
||
117 | * Register a breadcrumb domain. |
||
118 | * |
||
119 | * @param string $name |
||
120 | * @param \Closure $callback |
||
121 | * |
||
122 | * @return $this |
||
123 | */ |
||
124 | 54 | public function register($name, Closure $callback) |
|
132 | |||
133 | /** |
||
134 | * Render breadcrumbs items. |
||
135 | * |
||
136 | * @param string|null $name |
||
137 | * @param array $params |
||
138 | * |
||
139 | * @return \Illuminate\Support\HtmlString |
||
140 | */ |
||
141 | 18 | public function render($name = null, ...$params) |
|
149 | |||
150 | /** |
||
151 | * Generate the breadcrumbs. |
||
152 | * |
||
153 | * @param string $name |
||
154 | * @param array $params |
||
155 | * |
||
156 | * @return array |
||
157 | */ |
||
158 | 24 | public function generate($name, ...$params): array |
|
162 | |||
163 | /* ----------------------------------------------------------------- |
||
164 | | Check Methods |
||
165 | | ----------------------------------------------------------------- |
||
166 | */ |
||
167 | |||
168 | /** |
||
169 | * Check Template. |
||
170 | * |
||
171 | * @param string $template |
||
172 | * |
||
173 | * @throws Exceptions\InvalidTemplateException |
||
174 | * @throws Exceptions\InvalidTypeException |
||
175 | */ |
||
176 | 54 | private function checkTemplate($template): void |
|
193 | |||
194 | /** |
||
195 | * Check Name. |
||
196 | * |
||
197 | * @param string $name |
||
198 | * |
||
199 | * @throws Exceptions\InvalidTypeException |
||
200 | */ |
||
201 | 54 | private function checkCallbackName(&$name): void |
|
213 | } |
||
214 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: