<commit_before><?php
/**
 * ArrayX class file.
 *
 * @author <NAME> <<EMAIL>>
 * @link http://www.ramirezcobos.com/
 * @link http://www.2amigos.us/
 * @copyright 2013 2amigOS! Consultation Group LLC
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 */
namespace Yiinitializr\Helpers;

/**
 * ArrayX provides a set of useful functions
 *
 * @author <NAME> <<EMAIL>>
 * @package Yiinitializr.helpers
 * @since 1.0
 */
class ArrayX
{
	/**
	 * Get an item from an array using "dot" notation.
	 *
	 * <code>
	 *        // Get the $array['user']['name'] value from the array
	 *        $name = ArrayX::get($array, 'user.name');
	 *
	 *        // Return a default from if the specified item doesn't exist
	 *        $name = ArrayX::get($array, 'user.name', 'Taylor');
	 * </code>
	 *
	 * @param  array $array
	 * @param  string $key
	 * @param  mixed $default
	 * @return mixed
	 */
	public static function get($array, $key, $default = null)
	{
		if (is_null($key)) return $array;

		// To retrieve the array item using dot syntax, we'll iterate through
		// each segment in the key and look for that value. If it exists, we
		// will return it, otherwise we will set the depth of the array and
		// look for the next segment.
		foreach (explode('.', $key) as $segment)
		{
			if (!is_array($array) || !array_key_exists($segment, $array))
			{
				return self::value($default);
			}

			$array = $array[$segment];
		}

		return $array;
	}

	/**
	 * Removes an item from the given options and returns the value.
	 *
	 * If no key is found, then default value will be returned.
	 *
	 * @param $array
	 * @param $key
	 * @param null $default
	 * @return mixed|null
	 */
	public static function pop(&$array, $key, $default = null)<commit_msg>Adding ability to find requited value from CAttributeCollection<commit_after><?php
/**
 * ArrayX class file.
 *
 * @author <NAME> <<EMAIL>>
 * @link http://www.ramirezcobos.com/
 * @link http://www.2amigos.us/
 * @copyright 2013 2amigOS! Consultation Group LLC
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 */
namespace Yiinitializr\Helpers;

/**
 * ArrayX provides a set of useful functions
 *
 * @author <NAME> <<EMAIL>>
 * @package Yiinitializr.helpers
 * @since 1.0
 */
class ArrayX
{
	/**
	 * Get an item from an array using "dot" notation.
	 *
	 * <code>
	 *        // Get the $array['user']['name'] value from the array
	 *        $name = ArrayX::get($array, 'user.name');
	 *
	 *        // Return a default from if the specified item doesn't exist
	 *        $name = ArrayX::get($array, 'user.name', 'Taylor');
	 * </code>
	 *
	 * @param  array $array
	 * @param  string $key
	 * @param  mixed $default
	 * @return mixed
	 */
	public static function get($array, $key, $default = null)
	{
		if (is_null($key)) return $array;

		// In case if given array is instance of CAttributeCollection.
		// For example, Yii::app()->params value
		if($array instanceof \CAttributeCollection) $array = $array->toArray();

		// To retrieve the array item using dot syntax, we'll iterate through
		// each segment in the key and look for that value. If it exists, we
		// will return it, otherwise we will set the depth of the array and
		// look for the next segment.
		foreach (explode('.', $key) as $segment)
		{
			if (!is_array($array) || !array_key_exists($segment, $array))
			{
				return self::value($default);
			}

			$array = $array[$segment];
		}

		return $array;
	}

	/**
	 * Removes an item from the given options and returns the value.
	 *
	 * If no key is found, then default value will be returned.
	 *
	 * @param $array
	 * @param $key
	 * @param null $default
	 * @return mixed|null
	 */
	public static function pop(&$array, $key, $default = null)
{'fraction_non_alphanumeric': 0.14327563249001332, 'fraction_numerical': 0.004260985352862849, 'mean_word_length': 3.0474137931034484, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '6298752', 'n_tokens_mistral': 1292, 'n_tokens_neox': 1172, 'n_words': 410}