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