1 | <?php |
||
10 | trait HasAttributes |
||
11 | { |
||
12 | /** |
||
13 | * @var Attributes |
||
14 | */ |
||
15 | protected $attributes; |
||
16 | |||
17 | /** |
||
18 | * Get attributes object. |
||
19 | * If send \Closure option as parameter then returned callback result. |
||
20 | * |
||
21 | * @param callable|null $callback |
||
22 | * @return Attributes|mixed |
||
23 | */ |
||
24 | 4 | public function getAttributes($callback = null) |
|
25 | { |
||
26 | 4 | if (is_callable($callback)) { |
|
27 | 1 | return call_user_func($callback, $this->attributes); |
|
28 | } |
||
29 | |||
30 | 3 | return $this->attributes; |
|
31 | } |
||
32 | |||
33 | /** |
||
34 | * Build attributes to html valid string |
||
35 | * |
||
36 | * @param array $attributes |
||
37 | * @return string |
||
38 | */ |
||
39 | 6 | public function buildAttributes($attributes = []) |
|
43 | } |