1 | <?php |
||
5 | trait HasTextAttributes |
||
6 | { |
||
7 | /** |
||
8 | * Prepend the anchor with a string of html on render. |
||
9 | * |
||
10 | * @param string $prepend |
||
11 | * |
||
12 | * @return $this |
||
13 | */ |
||
14 | public function prepend(string $prepend) |
||
20 | |||
21 | /** |
||
22 | * Prepend the text with a string of html on render if a certain condition is |
||
23 | * met. |
||
24 | * |
||
25 | * @param bool $condition |
||
26 | * @param string $prepend |
||
27 | * |
||
28 | * @return $this |
||
29 | */ |
||
30 | public function prependIf($condition, string $prepend) |
||
38 | |||
39 | /** |
||
40 | * Append a text of html to the menu on render. |
||
41 | * |
||
42 | * @param string $append |
||
43 | * |
||
44 | * @return $this |
||
45 | */ |
||
46 | public function append(string $append) |
||
52 | |||
53 | /** |
||
54 | * Append the text with a string of html on render if a certain condition is |
||
55 | * met. |
||
56 | * |
||
57 | * @param bool $condition |
||
58 | * @param string $append |
||
59 | * |
||
60 | * @return static |
||
61 | */ |
||
62 | public function appendIf($condition, string $append) |
||
70 | } |
||
71 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: