Conditions | 3 |
Paths | 3 |
Total Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
43 | public function serializeDataAttributes(array $dataAttributes): string |
||
44 | { |
||
45 | $result = ''; |
||
46 | foreach ($dataAttributes as $attributeName => $attributeValue) { |
||
47 | if (!is_string($attributeValue)) { |
||
48 | $attributeValue = json_encode($attributeValue); |
||
49 | } |
||
50 | |||
51 | $result .= sprintf('data-%s="%s" ', $attributeName, htmlspecialchars($attributeValue)); |
||
52 | } |
||
53 | |||
54 | return rtrim($result); |
||
55 | } |
||
56 | } |
||
57 |