1 | <?php |
||
11 | final class BreadCrumbBuilder |
||
12 | { |
||
13 | /** |
||
14 | * @var bool |
||
15 | */ |
||
16 | private $extractFromRoute = true; |
||
17 | |||
18 | /** |
||
19 | * @var EventDispatcherInterface |
||
20 | */ |
||
21 | private $eventDispatcher; |
||
22 | |||
23 | /** |
||
24 | * @var FactoryInterface |
||
25 | */ |
||
26 | private $factory; |
||
27 | |||
28 | /** |
||
29 | * @var array |
||
30 | */ |
||
31 | private $items = []; |
||
32 | |||
33 | /** |
||
34 | * @param FactoryInterface $factory |
||
35 | * @param EventDispatcherInterface $eventDispatcher |
||
36 | */ |
||
37 | 14 | public function __construct(FactoryInterface $factory, EventDispatcherInterface $eventDispatcher) |
|
42 | |||
43 | /** |
||
44 | * @param RequestStack $requestStack |
||
45 | * @return \Knp\Menu\ItemInterface |
||
46 | */ |
||
47 | 14 | public function createBreadCrumb(RequestStack $requestStack) |
|
65 | |||
66 | /** |
||
67 | * @return BreadCrumbBuilder |
||
68 | */ |
||
69 | 14 | public function dontExtractFromTheRequest() |
|
75 | |||
76 | /** |
||
77 | * Extract the items for the breadcrumb based on a uri |
||
78 | * |
||
79 | * @param string $uri |
||
80 | * @param string $locale |
||
81 | * @return BreadCrumbBuilder |
||
82 | */ |
||
83 | 11 | public function extractItemsBasedOnUri($uri, $locale) |
|
98 | |||
99 | /** |
||
100 | * Add an item into the breadcrumb |
||
101 | * |
||
102 | * @param MenuItem $item |
||
103 | * @return BreadCrumbBuilder |
||
104 | */ |
||
105 | 1 | public function addItem(MenuItem $item) |
|
111 | |||
112 | /** |
||
113 | * Add a item into the breadcrumb by passing the label and an optional URI. |
||
114 | * |
||
115 | * @param string $label |
||
116 | * @param string $uri |
||
117 | * @return BreadCrumbBuilder |
||
118 | */ |
||
119 | 2 | public function addSimpleItem($label, $uri = null) |
|
131 | |||
132 | /** |
||
133 | * Reset the items and add the given items all at once |
||
134 | * |
||
135 | * @param array $items |
||
136 | * @return BreadCrumbBuilder |
||
137 | */ |
||
138 | 1 | public function overwriteItems(array $items) |
|
144 | |||
145 | /** |
||
146 | * Add items into the breadcrumb based on a given child. |
||
147 | * |
||
148 | * @param MenuItem $item |
||
149 | * @param string $locale |
||
150 | */ |
||
151 | 3 | private function addItemsBasedOnTheChild(MenuItem $item, $locale) |
|
177 | |||
178 | /** |
||
179 | * Grab the menu |
||
180 | * |
||
181 | * This method will use the ConfigureMenuEvent to get all the items |
||
182 | * |
||
183 | * @return \Knp\Menu\ItemInterface |
||
184 | */ |
||
185 | 11 | private function getTheMenu() |
|
199 | |||
200 | /** |
||
201 | * Find an item in the menu based on its URI |
||
202 | * |
||
203 | * @param MenuItem $menuItem |
||
204 | * @param $uri |
||
205 | * @return MenuItem|null |
||
206 | */ |
||
207 | 11 | private function findItemBasedOnUri(MenuItem $menuItem, $uri) |
|
230 | |||
231 | /** |
||
232 | * Extract the items for the breadcrumb based on request |
||
233 | * |
||
234 | * @param RequestStack $requestStack |
||
235 | */ |
||
236 | 14 | private function extractItemsBasedOnTheRequest(RequestStack $requestStack) |
|
247 | } |
||
248 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.