<?php

declare(strict_types=1);

namespace SeoScope\i18n;

final class Locale
{
    public function __construct(
        private string $code,
        private string $messagesPath
    ) {
    }

    public function code(): string
    {
        return $this->code;
    }

    /**
     * @return array<string, string>
     */
    public function loadMessages(): array
    {
        if (!is_readable($this->messagesPath)) {
            return [];
        }
        $data = require $this->messagesPath;
        return is_array($data) ? $data : [];
    }
}
