<commit_before><?php


namespace Configula;

use Configula\Exception\ConfigLogicException;
use Configula\Util\RecursiveArrayMerger;
use Dflydev\DotAccessData\Data;
use Configula\Exception\ConfigValueNotFoundException;

/**
 * Class ConfigValues
 *
 * @package Configula
 */
class ConfigValues implements \IteratorAggregate, \Countable, \ArrayAccess
{
    const NOT_SET = '__THe_VALUe___iS__Not_SET_l33t__';

    /**
     * @var Data
     */
    private $values;

    /**
     * Construct from other config values
     *
     * @param ConfigValues $configValues
     * @return ConfigValues|static
     */
    public static function fromConfigValues(ConfigValues $configValues)
    {
        return new static($configValues->getArrayCopy());
    }

    /**
     * Config constructor.
     *
     * @param array $values
     */
    public function __construct(array $values)
    {
        $this->values = new Data($values);
    }

    /**
     * Magic method - Get a value or path, or throw an exception
     *
     * @param string $path
     * @return mixed
     * @throws ConfigValueNotFoundException  If the config value is not found
     */
    public function __get(string $path)
    {
        return $this->get($path);
    }

    /**
     * Magic method - Check if a value or path exists
     *
     * @param string $path
     * @return bool
     */
    public function __isset(string $path): bool
    {
        return $this->has($path);
    }

    /**
     * Get a values
     *
     * @param string $path Accepts '.' path notation
     * @param mixed $default
     * @return array|mixed|null
     */
    public function get(string $path, $default = self::NOT_SET)
    {
        $result = $this->values->get($path, $default);

        if ($result === self::NOT_SET) {
            throw new ConfigValueNotFoundException('Config value not found: ' . $path);
        }

        return $result;
    }

    /**
     * Check if value exists (even if it is null)
     *
     * @param string $path
     * @return bool
     */
    public function has(string $path): bool<commit_msg>Add `find` method to `ConfigValues` for optional values.<commit_after><?php


namespace Configula;

use Configula\Exception\ConfigLogicException;
use Configula\Util\RecursiveArrayMerger;
use Dflydev\DotAccessData\Data;
use Configula\Exception\ConfigValueNotFoundException;

/**
 * Class ConfigValues
 *
 * @package Configula
 */
class ConfigValues implements \IteratorAggregate, \Countable, \ArrayAccess
{
    const NOT_SET = '__THe_VALUe___iS__Not_SET_l33t__';

    /**
     * @var Data
     */
    private $values;

    /**
     * Construct from other config values
     *
     * @param ConfigValues $configValues
     * @return ConfigValues|static
     */
    public static function fromConfigValues(ConfigValues $configValues)
    {
        return new static($configValues->getArrayCopy());
    }

    /**
     * Config constructor.
     *
     * @param array $values
     */
    public function __construct(array $values)
    {
        $this->values = new Data($values);
    }

    /**
     * Magic method - Get a value or path, or throw an exception
     *
     * @param string $path
     * @return mixed
     * @throws ConfigValueNotFoundException  If the config value is not found
     */
    public function __get(string $path)
    {
        return $this->get($path);
    }

    /**
     * Magic method - Check if a value or path exists
     *
     * @param string $path
     * @return bool
     */
    public function __isset(string $path): bool
    {
        return $this->has($path);
    }

    /**
     * Get a values
     *
     * @param string $path Accepts '.' path notation
     * @param mixed $default
     * @return array|mixed|null
     */
    public function get(string $path, $default = self::NOT_SET)
    {
        $result = $this->values->get($path, $default);

        if ($result === self::NOT_SET) {
            throw new ConfigValueNotFoundException('Config value not found: ' . $path);
        }

        return $result;
    }

    /**
     * Find a configuration value, or return NULL if not found
     *
     * This is different than the get() method in that it will always return NULL
     * if the value doesn't exist or is not set, rather than throw an exception.
     *
     * @param string $path
     * @return array|mixed|null
     */
    public function find(string $path)
    {
        return $this->values->get($path, null);
    }

    /**
     * Check if value exists (even if it is null)
     *
     * @param string $path
     * @return bool
     */
    public function has(string $path): bool
{'fraction_non_alphanumeric': 0.10949696444058976, 'fraction_numerical': 0.0008673026886383347, 'mean_word_length': 2.304441260744986, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '3353286', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1320, 'n_words': 384}