2 declare(strict_types = 1);
48 public function addProperty(
string $property,
string $content, array $subProperties = [],
bool $replace =
false,
string $type =
'name')
50 $property = strtolower($property);
51 $type = strtolower($type) ?:
'name';
57 $this->properties[$property][$type][] = [
58 'content' => $content,
59 'subProperties' => $subProperties
70 public function getProperty(
string $property,
string $type =
'name'): array
72 $property = strtolower($property);
73 $type = strtolower($type) ?:
'name';
75 if (!empty($this->properties[$property][$type])) {
76 return $this->properties[$property][$type];
98 foreach (array_keys($this->properties) as $property) {
102 return implode(PHP_EOL, $metatags);
113 $property = strtolower($property);
116 foreach ((array)$this->properties[$property] as $type => $propertyItems) {
117 foreach ($propertyItems as $propertyItem) {
118 $metaTags[] =
'<meta ' .
119 htmlspecialchars($type) .
'="' . htmlspecialchars($property) .
'" ' .
120 'content="' . htmlspecialchars($propertyItem[
'content']) .
'" />';
122 if (!count($propertyItem[
'subProperties'])) {
125 foreach ($propertyItem[
'subProperties'] as $subProperty => $value) {
126 $metaTags[] =
'<meta ' .
127 htmlspecialchars($type) .
'="' . htmlspecialchars($property . $this->subPropertySeparator . $subProperty) .
'" ' .
128 'content="' . htmlspecialchars((
string)$value) .
'" />';
133 return implode(PHP_EOL, $metaTags);
146 unset($this->properties[$property][$type]);
148 unset($this->properties[$property]);
157 $this->properties = [];