Total Complexity | 5 |
Total Lines | 54 |
Duplicated Lines | 0 % |
Coverage | 83.33% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
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; |
|
|
|||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Get the crumb URL. |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | 1 | public function url() |
|
63 | } |
||
64 | } |
||
65 |