Try to get stuff working

This commit is contained in:
brabli
2025-11-27 14:37:29 +00:00
parent d48fb65010
commit 91e21013ec
9 changed files with 118 additions and 96 deletions

43
src/Model/Metadata.php Normal file
View File

@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace Pcm\MetadataBundle\Model;
use App\Exception\Dto\Metadata\MissingKeyException;
use App\Interface\Dto\MetadataInterface;
/**
* Store scalar metadata on an entity.
*/
final class Metadata implements MetadataInterface
{
/**
* @param array<string, scalar|scalar[]> &$metadata
*/
public function __construct(private array &$metadata)
{
}
public function get(string $key): mixed
{
if (!$this->has($key)) {
throw new MissingKeyException($key);
}
return $this->metadata[$key];
}
public function set(string $key, mixed $value): static
{
$this->metadata[$key] = $value;
return $this;
}
public function has(string $key): bool
{
return array_key_exists($key, $this->metadata);
}
}