diff --git a/packages/framework/src/Framework/Features/Metadata/MetadataBag.php b/packages/framework/src/Framework/Features/Metadata/MetadataBag.php index 346fd8a4357..51e55491691 100644 --- a/packages/framework/src/Framework/Features/Metadata/MetadataBag.php +++ b/packages/framework/src/Framework/Features/Metadata/MetadataBag.php @@ -55,21 +55,15 @@ public function get(): array public function add(MetadataElementContract|string $element): static { match (true) { - $element instanceof LinkElement => $this->addElement('links', $element), - $element instanceof MetadataElement => $this->addElement('metadata', $element), - $element instanceof OpenGraphElement => $this->addElement('properties', $element), + $element instanceof LinkElement => $this->links[$element->uniqueKey()] = $element, + $element instanceof MetadataElement => $this->metadata[$element->uniqueKey()] = $element, + $element instanceof OpenGraphElement => $this->properties[$element->uniqueKey()] = $element, default => $this->addGenericElement((string) $element), }; return $this; } - /** @param 'links'|'metadata'|'properties' $type */ - protected function addElement(string $type, MetadataElementContract $element): void - { - $this->{$type}[$element->uniqueKey()] = $element; - } - protected function addGenericElement(string $element): void { $this->generics[] = $element;