1 | <?php |
||
2 | |||
3 | namespace SleepingOwl\Admin\Templates; |
||
4 | |||
5 | use DaveJamesMiller\Breadcrumbs\BreadcrumbsManager; |
||
6 | use DaveJamesMiller\Breadcrumbs\Exceptions\ViewNotSetException; |
||
7 | use SleepingOwl\Admin\Contracts\Template\BreadcrumbsInterface as BreadcrumbsContract; |
||
8 | |||
9 | class Breadcrumbs extends BreadcrumbsManager implements BreadcrumbsContract |
||
10 | { |
||
11 | /** |
||
12 | * @param string|null $name |
||
13 | * |
||
14 | * @return string |
||
15 | * @throws ViewNotSetException |
||
16 | * @throws \DaveJamesMiller\Breadcrumbs\Exceptions\InvalidBreadcrumbException |
||
17 | * @throws \DaveJamesMiller\Breadcrumbs\Exceptions\UnnamedRouteException |
||
18 | */ |
||
19 | public function renderIfExists($name = null) |
||
20 | { |
||
21 | if (is_null($name)) { |
||
22 | $params = $this->getCurrentRoute(); |
||
23 | $name = $params[0]; |
||
24 | } |
||
25 | |||
26 | if (! $this->exists($name)) { |
||
27 | return ''; |
||
28 | } |
||
29 | |||
30 | return $this->render($name); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * @param string $name |
||
35 | * @param array $params |
||
36 | * |
||
37 | * @return string |
||
38 | * @throws ViewNotSetException |
||
39 | * @throws \DaveJamesMiller\Breadcrumbs\Exceptions\InvalidBreadcrumbException |
||
40 | * @throws \DaveJamesMiller\Breadcrumbs\Exceptions\UnnamedRouteException |
||
41 | */ |
||
42 | public function renderArray($name, ...$params) |
||
43 | { |
||
44 | return $this->render($name, ...$params); |
||
45 | // return $this->view($this->generator->generate($this->callbacks, $name, $params)); |
||
0 ignored issues
–
show
|
|||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @param string $name |
||
50 | * @param array $params |
||
51 | * |
||
52 | * @return string |
||
53 | * @throws ViewNotSetException |
||
54 | * @throws \DaveJamesMiller\Breadcrumbs\Exceptions\InvalidBreadcrumbException |
||
55 | * @throws \DaveJamesMiller\Breadcrumbs\Exceptions\UnnamedRouteException |
||
56 | */ |
||
57 | public function renderIfExistsArray($name, $params = []) |
||
58 | { |
||
59 | if (! $this->exists($name)) { |
||
60 | return ''; |
||
61 | } |
||
62 | |||
63 | return $this->renderArray($name, $params); |
||
64 | } |
||
65 | } |
||
66 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.