| Conditions | 9 |
| Paths | 26 |
| Total Lines | 35 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 22 |
| CRAP Score | 9.0066 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | 12 | public function generateHtml(ObjectBase $object) |
|
| 26 | { |
||
| 27 | 12 | $html = ''; |
|
| 28 | 12 | $format = '<meta property="%s" content="%s"' . ($this->doctype == self::DOCTYPE_XHTML ? ' />' : '>'); |
|
| 29 | |||
| 30 | 12 | foreach ($object->getProperties() as $property) { |
|
| 31 | 12 | if ($html !== '') { |
|
| 32 | $html .= "\n"; |
||
| 33 | } |
||
| 34 | |||
| 35 | 12 | if ($property->value === null) { |
|
| 36 | 1 | continue; |
|
| 37 | } |
||
| 38 | 11 | if ($property->value instanceof DateTimeInterface) { |
|
| 39 | 1 | $value = $property->value->format('c'); |
|
| 40 | 10 | } elseif (is_object($property->value)) { |
|
| 41 | 1 | throw new UnexpectedValueException( |
|
| 42 | 1 | sprintf( |
|
| 43 | 1 | "Cannot handle value of type '%s' for property '%s'.", |
|
| 44 | 1 | get_class($property->value), |
|
| 45 | 1 | $property->key |
|
| 46 | ) |
||
| 47 | ); |
||
| 48 | 9 | } elseif ($property->value === true) { |
|
| 49 | 1 | $value = '1'; |
|
| 50 | 8 | } elseif ($property->value === false) { |
|
| 51 | 1 | $value = '0'; |
|
| 52 | } else { |
||
| 53 | 7 | $value = (string)$property->value; |
|
| 54 | } |
||
| 55 | |||
| 56 | 10 | $html .= sprintf($format, $property->key, htmlspecialchars($value)); |
|
| 57 | } |
||
| 58 | |||
| 59 | 11 | return $html; |
|
| 60 | } |
||
| 62 |