<?php

declare(strict_types=1);

namespace App\Framework\Database\Metadata;

use ReflectionClass;

final readonly class EntityMetadata
{
    public function __construct(
        public string $entityClass,
        public string $tableName,
        public string $idColumn,
        public string $idProperty,
        public ReflectionClass $reflection,
        public array $properties
    ) {
    }

    public function getProperty(string $name): ?PropertyMetadata
    {
        return $this->properties[$name] ?? null;
    }

    public function getColumnName(string $propertyName): string
    {
        $property = $this->getProperty($propertyName);

        return $property?->columnName ?? $propertyName;
    }
}
