<?php

declare(strict_types=1);

namespace App\DataFixtures;

use App\Entity\Signal;
use App\ValueObject\Point;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;

class SignalFixtures extends Fixture
{
    public function load(ObjectManager $manager): void
    {
        $coordinates = [
            [
                'user' => 'user-alpha',
                'lat' => -11.6877,
                'lng' => 27.5026,
                'offset' => 0,
            ],
            [
                'user' => 'user-beta',
                'lat' => -11.6895,
                'lng' => 27.5081,
                'offset' => 3,
            ],
            [
                'user' => 'user-alpha',
                'lat' => -11.6852,
                'lng' => 27.4974,
                'offset' => 6,
            ],
        ];

        foreach ($coordinates as $config) {
            $signalLocation = Point::fromLatLng($config['lat'], $config['lng']);

            $signal = Signal::create(
                $config['user'],
                Point::fromLatLng($config['lat'], $config['lng']),
                $signalLocation,
            );

            $manager->persist($signal);
        }

        $manager->flush();
    }
}
