chore: complete update
This commit is contained in:
33
src/Framework/Database/Metadata/MetadataRegistry.php
Normal file
33
src/Framework/Database/Metadata/MetadataRegistry.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Database\Metadata;
|
||||
|
||||
final class MetadataRegistry
|
||||
{
|
||||
private array $metadata = [];
|
||||
|
||||
public function __construct(
|
||||
private readonly MetadataExtractor $extractor
|
||||
) {}
|
||||
|
||||
public function getMetadata(string $entityClass): EntityMetadata
|
||||
{
|
||||
if (!isset($this->metadata[$entityClass])) {
|
||||
$this->metadata[$entityClass] = $this->extractor->extractMetadata($entityClass);
|
||||
}
|
||||
|
||||
return $this->metadata[$entityClass];
|
||||
}
|
||||
|
||||
public function hasMetadata(string $entityClass): bool
|
||||
{
|
||||
return isset($this->metadata[$entityClass]);
|
||||
}
|
||||
|
||||
public function clearCache(): void
|
||||
{
|
||||
$this->metadata = [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user