<commit_before><?php
namespace kartik\icons;
use Yii;
use yii\helpers\Html;
use yii\base\InvalidConfigException;

/**
 * Icon is a class for setting up icon frameworks to work with Yii in an easy way
 * To setup a global default icon framework, you can set the Yii param 'icon-framework' 
 * to one of the following values in your config file:
 * - 'fa' for Font Awesome Icons
 * - 'el' for Elusive Font Icons
 * - 'typ' for Typicon Font Icons
 * - 'whhg' for Web Hosting Hub Glyphs Icons
 * - 'jui' for JQuery UI Icons
 * 
 * @author <NAME> <<EMAIL>>
 */
class Icon 
{
	const NS = '\\kartik\\icons\\';
	const PARAM_NOT_SET = "The 'icon-framework' option has not been setup in Yii params. Check your configuration file.";
	const PARAM_INVALID = "Invalid or non-recognized 'icon-framework' has been setup in Yii params. Check your configuration file.";

	/**
	 * Icon framework constants
	 */
	const FA = 'fa';
	const EL = 'el';
	const TYP = 'typ';
	const WHHG = 'whhg';
	const JUI = 'jui';
	
	/**
	 * Icon framework configurations
	 */
	private static $_frameworks = [
		self::FA => ['prefix' => 'fa fa-', 'class' => 'FontAwesomeAsset'],
		self::EL => ['prefix' => 'el-icon-', 'class' => 'ElusiveAsset'],
		self::TYP => ['prefix' => 'typcn typcn-', 'class' => 'TypiconsAsset'],
		self::WHHG => ['prefix' => 'icon-', 'class' => 'WhhgAsset'],
		self::JUI => ['prefix' => 'ui-icon ui-icon-', 'class' => '\\yii\\jui\\ThemeAsset']
	];
	
	/**
	 * Returns the font framework setup from Yii parameters.
	 *
	 * @var string the framework to be used with the application
	 * @throws InvalidConfigException
	 */
	protected static function getFramework($framework = null) {
		if (strlen($framework) == 0 && empty(Yii::$app->params['icon-framework'])) {
			throw new InvalidConfigException(static::PARAM_NOT_SET);
		}
		elseif (strlen($framework) == 0) {
			$framework = Yii::$app->params['icon-framework'];
		}
		if (!in_array(Yii::$app->params['icon-framework'], array_keys(self::$_frameworks))) {
			throw new InvalidConfigException(static::PARAM_INVALID);
		}
		return $framework;
	}
	
	/**
	 * Maps the icon framework to the current view. Call this in your view or layout file.
	 *
	 * @param object $view the view object
	 * @param string $framework the name of the framework, if not passed it will default to
	 * the Yii config param 'icon-framework'
	 */
	public static function map($view, $framework = null) {
		$key = static::getFramework($framework);
		$class = self::$_frameworks[$key]['class'];
		if (substr($class, 0, 1) != '\\') {
			$class = static::NS . $class;
		}
		$class::register($view);
	}

	/**<commit_msg>Conditional bug in getFramework corrected<commit_after><?php
namespace kartik\icons;
use Yii;
use yii\helpers\Html;
use yii\base\InvalidConfigException;

/**
 * Icon is a class for setting up icon frameworks to work with Yii in an easy way
 * To setup a global default icon framework, you can set the Yii param 'icon-framework' 
 * to one of the following values in your config file:
 * - 'fa' for Font Awesome Icons
 * - 'el' for Elusive Font Icons
 * - 'typ' for Typicon Font Icons
 * - 'whhg' for Web Hosting Hub Glyphs Icons
 * - 'jui' for JQuery UI Icons
 * 
 * @author <NAME> <<EMAIL>>
 */
class Icon 
{
	const NS = '\\kartik\\icons\\';
	const PARAM_NOT_SET = "The 'icon-framework' option has not been setup in Yii params. Check your configuration file.";
	const PARAM_INVALID = "Invalid or non-recognized 'icon-framework' has been setup in Yii params. Check your configuration file.";

	/**
	 * Icon framework constants
	 */
	const FA = 'fa';
	const EL = 'el';
	const TYP = 'typ';
	const WHHG = 'whhg';
	const JUI = 'jui';
	
	/**
	 * Icon framework configurations
	 */
	private static $_frameworks = [
		self::FA => ['prefix' => 'fa fa-', 'class' => 'FontAwesomeAsset'],
		self::EL => ['prefix' => 'el-icon-', 'class' => 'ElusiveAsset'],
		self::TYP => ['prefix' => 'typcn typcn-', 'class' => 'TypiconsAsset'],
		self::WHHG => ['prefix' => 'icon-', 'class' => 'WhhgAsset'],
		self::JUI => ['prefix' => 'ui-icon ui-icon-', 'class' => '\\yii\\jui\\ThemeAsset']
	];
	
	/**
	 * Returns the font framework setup from Yii parameters.
	 *
	 * @var string the framework to be used with the application
	 * @throws InvalidConfigException
	 */
	protected static function getFramework($framework = null) {
		if (strlen($framework) == 0 && empty(Yii::$app->params['icon-framework'])) {
			throw new InvalidConfigException(static::PARAM_NOT_SET);
		}
		if (!in_array(Yii::$app->params['icon-framework'], array_keys(self::$_frameworks))) {
			throw new InvalidConfigException(static::PARAM_INVALID);
		}		
		if (strlen($framework) == 0) {
			return Yii::$app->params['icon-framework'];
		}
		return $framework;
	}
	
	/**
	 * Maps the icon framework to the current view. Call this in your view or layout file.
	 *
	 * @param object $view the view object
	 * @param string $framework the name of the framework, if not passed it will default to
	 * the Yii config param 'icon-framework'
	 */
	public static function map($view, $framework = null) {
		$key = static::getFramework($framework);
		$class = self::$_frameworks[$key]['class'];
		if (substr($class, 0, 1) != '\\') {
			$class = static::NS . $class;
		}
		$class::register($view);
	}

	/**
{'fraction_non_alphanumeric': 0.1575942139322421, 'fraction_numerical': 0.0015226494099733537, 'mean_word_length': 3.8299632352941178, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4688693', 'n_tokens_mistral': 1773, 'n_tokens_neox': 1658, 'n_words': 552}