<?php

declare(strict_types=1);

namespace CliqThemes\StoreLocator\Geocoding;

defined('ABSPATH') || exit;

/**
 * Immutable result of a (forward or reverse) geocode lookup.
 */
final class GeocodeResult
{
    public function __construct(
        public readonly float $latitude,
        public readonly float $longitude,
        public readonly string $formatted = '',
        /** @var array<string, mixed> */
        public readonly array $components = []
    ) {
    }

    /**
     * @return array<string, mixed>
     */
    public function toArray(): array
    {
        return [
            'latitude' => $this->latitude,
            'longitude' => $this->longitude,
            'formatted' => $this->formatted,
            'components' => $this->components,
        ];
    }
}
