<?php

namespace App\DBRealTestSupport\TransactionSupported\LodgingPlace;

use App\DBRealTestSupport\TransactionSupported\TSRepositoryMother;
use App\Modules\LodgingPlace\Domain\IdLodgingPlace;
use App\Modules\LodgingPlace\Domain\LodgingPlaceName;
use App\Modules\LodgingPlace\Domain\LodgingPlaceRepository;
use App\DBRealTestSupport\TableCreation as TC;
use App\Modules\Booking\Domain\IdBooking;
use App\Modules\LodgingPlace\Domain\LodgingPlace;
use App\Modules\LodgingPlace\Domain\LodgingPlaceDirection;
use App\Modules\LodgingPlace\Domain\LodgingPlaceIcon;
use App\Modules\LodgingPlace\Domain\LodgingPlaceLatitude;
use App\Modules\LodgingPlace\Domain\LodgingPlaceLongitude;
use App\Modules\LodgingPlace\Domain\LodgingPlacePlace;
use App\Modules\LodgingPlace\Domain\LodgingPlaceStatus;
use App\Modules\LodgingPlace\Domain\LodgingPlaceVersion;
use Faker\Factory;

class TSLodgingPlaceMother
{
    public static function clear()
    {
        TC::clearTables(
            TC::LODGING_PLACE,
        );
    }
    public static function random(
        ?IdLodgingPlace $idLodgingPlace = null,
        ?LodgingPlaceVersion $version = null,
        ?IdBooking $idBooking = null,
        ?string $icon = null
    ): LodgingPlace {
        $faker = Factory::create();
        return new LodgingPlace(
            $idLodgingPlace ?? new IdLodgingPlace(0),
            new LodgingPlaceName($faker->text(rand(5, 250))),
            new LodgingPlaceDirection($faker->text(rand(5, 500))),
            new LodgingPlaceLongitude($faker->text(rand(5, 250))),
            new LodgingPlaceLatitude($faker->text(rand(5, 250))),
            $version ?? new LodgingPlaceVersion(rand(1, 1000)),
            new LodgingPlaceStatus($faker->randomElement(LodgingPlaceStatus::validValues())),
            // new LodgingPlaceIcon($faker->text(rand(5, 500))),
            new LodgingPlaceIcon($icon ?? $faker->text(rand(5, 500))),
            new LodgingPlacePlace($faker->text(rand(5, 500))),
            $idBooking ?? new IdBooking(0),
        );
    }

    public static function push(LodgingPlace $model): LodgingPlace
    {
        return TSRepositoryMother::push(LodgingPlaceRepository::class, $model);
    }
}
