1 | <?php |
||
2 | |||
3 | namespace ByTIC\Navigation\Breadcrumbs; |
||
4 | |||
5 | /** |
||
6 | * Class Crumb |
||
7 | * @package ByTIC\Navigation\Breadcrumbs |
||
8 | */ |
||
9 | class Crumb |
||
10 | { |
||
11 | /** |
||
12 | * The crumb title. |
||
13 | * |
||
14 | * @var string|callable |
||
15 | */ |
||
16 | protected $title; |
||
17 | |||
18 | /** |
||
19 | * The crumb URL. |
||
20 | * |
||
21 | * @var string|callable |
||
22 | */ |
||
23 | protected $url; |
||
24 | |||
25 | /** |
||
26 | * Construct the crumb instance. |
||
27 | * |
||
28 | * @param string $title |
||
29 | * @param string $url |
||
30 | * |
||
31 | * @return void |
||
32 | */ |
||
33 | 3 | public function __construct($title, $url = null) |
|
34 | { |
||
35 | 3 | $this->title = $title; |
|
36 | 3 | $this->url = $url; |
|
37 | 3 | } |
|
38 | |||
39 | /** |
||
40 | * Get the crumb title. |
||
41 | * |
||
42 | * @return string |
||
43 | */ |
||
44 | 1 | public function title(): string |
|
45 | { |
||
46 | 1 | if (is_callable($this->title)) { |
|
47 | $this->title = call_user_func($this->title); |
||
48 | } |
||
49 | 1 | return $this->title; |
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Get the crumb URL. |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | 1 | public function url() |
|
58 | { |
||
59 | 1 | if (is_callable($this->url)) { |
|
60 | $this->url = call_user_func($this->url); |
||
61 | } |
||
62 | 1 | return $this->url; |
|
0 ignored issues
–
show
|
|||
63 | } |
||
64 | } |
||
65 |