1 | <?php |
||
21 | trait AttributesAwareMethods |
||
22 | { |
||
23 | |||
24 | /** |
||
25 | * @var AttributesMapInterface |
||
26 | */ |
||
27 | protected $attributes; |
||
28 | |||
29 | /** |
||
30 | * Set an HTML tag attribute |
||
31 | * |
||
32 | * @param string $name |
||
33 | * @param string $value |
||
34 | * |
||
35 | * @return self|$this|ElementInterface |
||
36 | */ |
||
37 | 88 | public function setAttribute($name, $value = null) |
|
42 | |||
43 | /** |
||
44 | * Gets the value of the attribute with the provided name |
||
45 | * |
||
46 | * If there is no attribute with provided name, the default value |
||
47 | * SHOULD be returned. |
||
48 | * |
||
49 | * @param string $name |
||
50 | * @param null|string $default |
||
51 | * |
||
52 | * @return null|string |
||
53 | */ |
||
54 | 84 | public function getAttribute($name, $default = null) |
|
62 | |||
63 | /** |
||
64 | * Check if the provided attribute is set/exists |
||
65 | * |
||
66 | * @param string $name |
||
67 | * |
||
68 | * @return boolean True if attribute with name exists, false otherwise |
||
69 | */ |
||
70 | 88 | public function hasAttribute($name) |
|
75 | |||
76 | /** |
||
77 | * Get the attributes map collection |
||
78 | * |
||
79 | * @return AttributesMapInterface |
||
80 | */ |
||
81 | 116 | public function getAttributes() |
|
88 | |||
89 | /** |
||
90 | * Sets the attribute map collection |
||
91 | * |
||
92 | * @param AttributesMapInterface $attributes |
||
93 | * |
||
94 | * @return self|$this|ElementInterface |
||
95 | */ |
||
96 | 116 | public function setAttributes(AttributesMapInterface $attributes) |
|
101 | } |