<?php

namespace App\Modules\LodgingPlace\Domain;

use App\Modules\Booking\Domain\IdBooking;
use App\Modules\FactUnit\Domain\IdFactUnit;
use App\Modules\Shared\Domain\Aggregate\AggregateAttribute;
use App\Modules\Shared\Domain\Aggregate\AggregateRoot;
use App\Modules\TypeProvider\Domain\IdTypeProvider;

class LodgingPlace extends AggregateRoot
{

    /** @return AgregateAttribute[] */
    public static function attributes(): array
    {
        return [
            new AggregateAttribute('id', IdLodgingPlace::class, 'Id_LodgingPlace', 'primary'),
            new AggregateAttribute('name', LodgingPlaceName::class, 'LodgingPlace_Name'),
            new AggregateAttribute('direction', LodgingPlaceDirection::class, 'LodgingPlace_Direction'),
            new AggregateAttribute('longitude', LodgingPlaceLongitude::class, 'LodgingPlace_Longitude'),
            new AggregateAttribute('latitude', LodgingPlaceLatitude::class, 'LodgingPlace_Latitude'),
            new AggregateAttribute('version', LodgingPlaceVersion::class, 'LodgingPlace_Version'),
            new AggregateAttribute('status', LodgingPlaceStatus::class, 'LodgingPlace_Status'),
            new AggregateAttribute('icon', LodgingPlaceIcon::class, 'LodgingPlace_Icon'),
            new AggregateAttribute('place', LodgingPlacePlace::class, 'LodgingPlace_Place'),
            new AggregateAttribute('idBooking', IdBooking::class, 'Id_Booking'),
        ];
    }

    public static function table(): string
    {
        return 't_lodging_place';
    }

    public function __construct(
        protected IdLodgingPlace $id,
        protected LodgingPlaceName $name,
        protected LodgingPlaceDirection $direction,
        protected LodgingPlaceLongitude $longitude,
        protected LodgingPlaceLatitude $latitude,
        protected LodgingPlaceVersion $version,
        protected LodgingPlaceStatus $status,
        protected LodgingPlaceIcon $icon,
        protected LodgingPlacePlace $place,
        protected IdBooking $idBooking,
    ) {}

    public static function create(
        IdLodgingPlace $id,
        LodgingPlaceName $name,
        LodgingPlaceDirection $direction,
        LodgingPlaceLongitude $longitude,
        LodgingPlaceLatitude $latitude,
        LodgingPlaceVersion $version,
        LodgingPlaceStatus $status,
        LodgingPlaceIcon $icon,
        LodgingPlacePlace $place,
        IdBooking $idBooking,
    ) {
        $model = new self($id, $name, $direction, $longitude, $latitude, $version, $status, $icon, $place, $idBooking);
        return $model;
    }

    public function id(): IdLodgingPlace
    {
        return $this->id;
    }
    public function name(): LodgingPlaceName
    {
        return $this->name;
    }
    public function direction(): LodgingPlaceDirection
    {
        return $this->direction;
    }
    public function longitude(): LodgingPlaceLongitude
    {
        return $this->longitude;
    }
    public function latitude(): LodgingPlaceLatitude
    {
        return $this->latitude;
    }
    public function icon(): LodgingPlaceIcon
    {
        return $this->icon;
    }
    public function place(): LodgingPlacePlace
    {
        return $this->place;
    }
    public function idBooking(): IdBooking
    {
        return $this->idBooking;
    }

    public function setId(IdLodgingPlace $id): void
    {
        $this->id = $id;
    }

    public function setName(LodgingPlaceName $name): void
    {
        $this->name = $name;
    }
    public function setDirection(LodgingPlaceDirection $direction): void
    {
        $this->direction = $direction;
    }
    public function setLongitude(LodgingPlaceLongitude $longitude): void
    {
        $this->longitude = $longitude;
    }
    public function setLatitude(LodgingPlaceLatitude $latitude): void
    {
        $this->latitude = $latitude;
    }
    public function getVersion(): int
    {
        return $this->version()->value();
    }
    public function version(): LodgingPlaceVersion
    {
        return $this->version;
    }
    public function updateVersion(): void
    {
        $this->version = new LodgingPlaceVersion($this->version->value() + 1);
    }
    public function status(): LodgingPlaceStatus
    {
        return $this->status;
    }
    public function setStatus(LodgingPlaceStatus $status): void
    {
        $this->status = $status;
    }
    public function delete()
    {
        $this->status = new LodgingPlaceStatus(LodgingPlaceStatus::DELETED);
    }
    public function setIcon(LodgingPlaceIcon $icon): void
    {
        $this->icon = $icon;
    }
    public function setPlace(LodgingPlacePlace $place): void
    {
        $this->place = $place;
    }
    public function setIdBooking(IdBooking $idBooking): void
    {
        $this->idBooking = $idBooking;
    }
}
