<?php
/**
 * This file is part of the Wisewand WordPress plugin.
 *
 * @package Wisewand
 * @since 1.0.0
 * @license GPL-2.0-or-later
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 */
namespace Wisewand\Utils;

use Wisewand\Config\Supported_Options;

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Maps DataForSEO location codes to Wisewand country codes
 */
class Location_Mapper {

	/**
	 * Map location_code (DataForSEO) to country code (Wisewand API)
	 *
	 * @param int $location_code DataForSEO location code
	 * @return string Wisewand country code
	 */
	public static function location_to_country( $location_code ) {
		$mapping = Supported_Options::get_location_to_country_map();

		return $mapping[ $location_code ] ?? 'us';
	}

	/**
	 * Get language code from location code
	 *
	 * @param int $location_code DataForSEO location code
	 * @return string Language code
	 */
	public static function location_to_language( $location_code ) {
		$mapping = Supported_Options::get_location_to_language_map();

		return $mapping[ $location_code ] ?? 'en';
	}
}
