Conditions | 8 |
Paths | 6 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
9 | public static function getAttributeString(array $attributes): string |
||
10 | { |
||
11 | $finalAttributes = []; |
||
12 | |||
13 | foreach ($attributes as $attribute => $value) { |
||
14 | if (is_string($value) || is_numeric($value)) { |
||
15 | $finalAttributes[] = $attribute.'="'.$value.'"'; |
||
16 | } elseif ($value === true) { |
||
17 | $finalAttributes[] = $attribute; |
||
18 | } elseif ($value === false) { |
||
19 | $finalAttributes[] = $attribute.'="false"'; |
||
20 | } elseif (is_object($value) && method_exists($value, '__toString')) { |
||
21 | $finalAttributes[] = $attribute.'="'.$value->__toString().'"'; |
||
22 | } |
||
23 | } |
||
24 | |||
25 | return implode(' ', $finalAttributes); |
||
26 | } |
||
27 | |||
44 | } |