<?php

declare(strict_types=1);

namespace App\Exception;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\WithHttpStatus;
use function sprintf;

#[WithHttpStatus(Response::HTTP_UNPROCESSABLE_ENTITY, headers: [
    'x-error-code' => 'invalid_coordinates',
])]
final class InvalidPointException extends \DomainException
{
    public static function invalidNumber(): self
    {
        return new self('Latitude and longitude must be finite numbers.');
    }

    public static function latitudeOutOfRange(float $lat): self
    {
        return new self(sprintf('Latitude %.6f is out of bounds.', $lat));
    }

    public static function longitudeOutOfRange(float $lng): self
    {
        return new self(sprintf('Longitude %.6f is out of bounds.', $lng));
    }

    public static function missingCoordinates(): self
    {
        return new self('Missing latitude or longitude.');
    }
}
