| Conditions | 8 |
| Paths | 15 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 8.0189 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | 11 | public function __toString(): string |
|
| 25 | { |
||
| 26 | 11 | if ($this->attributes === null) { |
|
| 27 | 4 | return ''; |
|
| 28 | } |
||
| 29 | 9 | $result = []; |
|
| 30 | 9 | foreach ($this->attributes as $key => $value) { |
|
| 31 | 9 | if (is_int($key)) { |
|
| 32 | 1 | $key = $value; |
|
| 33 | 1 | $value = null; |
|
| 34 | } |
||
| 35 | 9 | if ($key === null || $key === '') { |
|
| 36 | continue; |
||
| 37 | } |
||
| 38 | 9 | if ($value === null) { |
|
| 39 | 1 | $result[] = sprintf("%s", $key); |
|
| 40 | 1 | continue; |
|
| 41 | } |
||
| 42 | 8 | $result[] = sprintf("%s='%s'", $key, $value); |
|
| 43 | } |
||
| 44 | |||
| 45 | 9 | return (empty($result)) ? '' : ' ' . implode(" ", $result); |
|
| 46 | } |
||
| 47 | } |