Implement IteratorAggregate

This commit is contained in:
brabli
2025-12-12 12:12:07 +00:00
parent adb75abb4e
commit fe133f1114

View File

@@ -10,7 +10,7 @@ use Pcm\MetadataBundle\Interface\MetadataInterface;
/**
* Store scalar metadata on an entity.
*/
final class Metadata implements MetadataInterface
final class Metadata implements MetadataInterface, \IteratorAggregate
{
/**
* @param array<string, scalar|scalar[]> &$metadata
@@ -19,6 +19,11 @@ final class Metadata implements MetadataInterface
{
}
public function getIterator(): \Traversable
{
return new \ArrayIterator($this->metadata);
}
public function get(string $key): mixed
{
if (!$this->isSet($key)) {