<?php
/**
 * Environment info.
 *
 * @package Ealab\Deployer
 */

namespace Ealab\Deployer\Utility;

use Dakwamine\Component\ComponentBasedObject;
use Throwable;

/**
 * Environment info.
 */
class Environment extends ComponentBasedObject {
	/**
	 * Tells if the current environment is the production environment.
	 *
	 * @return bool True if the current environment is the production environment, false otherwise.
	 *
	 * @throws Throwable Settings errors.
	 */
	public static function isProductionEnvironment(): bool {
		$dsc_settings_data = Settings::getInstance()->getAll();

		return ! empty( $dsc_settings_data['url_prod'] ) && rtrim( get_site_url(), '/' ) === rtrim( $dsc_settings_data['url_prod'], '/' );
	}
}
