<?php

declare(strict_types=1);

namespace apexl\Io\services;

use apexl\Io\collections\RelationCollection;
use apexl\Io\includes\Entity;

final class RelationDefinitionCache
{
    protected array $relations = [];

    public function get(Entity $entity): ?RelationCollection
    {
        return $this->relations[$entity::class] ?? null;
    }

    public function set(Entity $entity, RelationCollection $relations): void
    {
        $this->relations[$entity::class] = $relations;
    }

    public function has(Entity $entity): bool
    {
        return isset($this->relations[$entity::class]);
    }
}