<?php

declare(strict_types=1);

namespace apexl\Io\interfaces;

use apexl\entityCore\collections\EntityCollection;
use apexl\Io\dto\LoaderCondition;
use apexl\Io\includes\Entity;
use apexl\Vault\enums\WhereCondition;
use apexl\Vault\enums\WhereType;
use apexl\Vault\interfaces\driver;

interface RelationshipInterface
{
    public function getName(): string;

    public function getRemoteEntity(): Entity;

    public function lazyLoad(string|int $localKey);

    public function hydrate(array $data);

    public function getAliasedRemoteTable(): string;

    public function getLocalTable(): string;

    public function getRemoteTable(): string;

    public function with(string|array $key, mixed $value = null): static;

    public function freshEntity(): Entity;

    public function isDescendedFromOneToMany(): bool;

    public function set(int|array|EntityCollection|Entity $entity): void;

    public function add(Entity|int ...$entity1): void;

    public function remove(Entity|int $entity): void;

    public function clear(): void;

    public function valueWhenEmpty(): mixed;

    public function subSelectString(array $fields, ?string $table = null): string;

    public function subSelect(array $fields, ?string $table = null): driver;

    public function subSelectStringSingleField(string $field, ?string $table = null): string;

    public function loaderConditionForField(
        string $field,
        WhereCondition $condition,
        array|bool|float|int|null|string $value,
        WhereType $type = WhereType::AND
    ): LoaderCondition;

}
