<?php
/**
 * FiboFilters envs
 *
 * @package FiboFilters
 */

declare( strict_types=1 );

namespace FiboFilters\Config;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class Env
 */
class Env {
	/** @var string Plugin version */
	public static $version;
	/** @var string WordPress minimum version */
	public static $wp_min_version;
	/** @var string WooCommerce minimum version */
	public static $wc_min_version;
	/** @var string Plugin slug */
	public static $plugin_slug;
	/** @var string Plugin full name */
	public static $plugin_full_name;
	/** @var string Plugin full path */
	public static $plugin_path;
	/** @var string Plugin base URL */
	public static $base_url;
	/** @var string Plugin main file path */
	public static $file;
	/** @var string Plugin folder name */
	public static $plugin_folder;
	/** @var string Plugin path */
	public static $path;
	/** @var string Plugin assets path */
	public static $assets_path;
	/** @var string Plugin assets URL */
	public static $assets_url;
	/** @var string Plugin build URL */
	public static $build_url;
	/** @var string Plugin build path */
	public static $build_path;
	/** @var string Plugin static dir path */
	public static $static_path;
	/** @var string Plugin static dir URL */
	public static $static_url;
	/** @var string Plugin utils dir path */
	public static $util_path;
	/** @var string Plugin language dir path */
	public static $languages_path;
	/** @var string Plugin language dir path relative to WP_PLUGIN_DIR */
	public static $languages_path_rel;
	/** @var string Plugin lib dir path */
	public static $lib_path;
	/** @var string Plugin prefix */
	public static $plugin_prefix;
	/** @var string Plugin website URL */
	public static $website_url;
	/** @var string Plugin documentation URL */
	public static $doc_url;
	/** @var string Plugin cache directory */
	public static $cache_dir;
	/** @var string Plugin cache URL */
	public static $cache_url;

	/**
	 * Init envs
	 *
	 * @param string $file Main plugin file.
	 * @param array  $plugin_data Plugin data.
	 */
	public static function init( string $file, array $plugin_data ): void {
		$upload_dir = wp_get_upload_dir();

		self::$version            = $plugin_data['version'];
		self::$wp_min_version     = $plugin_data['wp_min_version'];
		self::$wc_min_version     = $plugin_data['wc_min_version'];
		self::$file               = $file;
		self::$plugin_folder      = dirname( plugin_basename( self::$file ) );
		self::$path               = dirname( self::$file );
		self::$plugin_slug        = 'fibofilters';
		self::$plugin_full_name   = '';
		self::$plugin_path        = 'fibofilters/fibofilters.php';
		self::$base_url           = plugins_url( '', $file );
		self::$assets_path        = self::$path . '/assets';
		self::$assets_url         = plugins_url( '/assets', $file );
		self::$build_url          = plugins_url( '/build', $file );
		self::$build_path         = self::$path . '/build';
		self::$static_path        = self::$path . '/static';
		self::$static_url         = plugins_url( '/static', $file );
		self::$util_path          = self::$path . '/lib/Util';
		self::$languages_path     = self::$path . '/languages';
		self::$languages_path_rel = self::$plugin_folder . '/languages';
		self::$lib_path           = self::$path . '/lib';
		self::$plugin_prefix      = 'fibofilters_';
		self::$website_url        = 'https://fibofilters.com';
		self::$doc_url            = self::$website_url . '/documentation/';
		self::$cache_dir          = $upload_dir['basedir'] . '/fibofilters';
		self::$cache_url          = $upload_dir['baseurl'] . '/fibofilters';
	}

	/**
	 * Set plugin full name
	 *
	 * @param string $plugin_full_name Plugin full name.
	 */
	public static function set_plugin_full_name( string $plugin_full_name ): void {
		self::$plugin_full_name = $plugin_full_name;
	}
}
