<commit_before><?php
/**
 * Kodekit - http://timble.net/kodekit
 *
 * @copyright   Copyright (C) 2007 - 2016 <NAME> and Timble CVBA. (http://www.timble.net)
 * @license     MPL v2.0 <https://www.mozilla.org/en-US/MPL/2.0>
 * @link        https://github.com/timble/kodekit for the canonical source repository
 */

namespace Kodekit\Library;

/**
 * ObjectConfig
 *
 * ObjectConfig provides a property based interface to an array.
 *
 * @author  <NAME> <https://github.com/johanjanssens>
 * @package Kodekit\Library\Object\Config
 */
class ObjectConfig implements ObjectConfigInterface
{
    /**
     * The configuration options
     *
     * @var array
     */
    private $__options = array();

    /**
     * Constructor.
     *
     * @param  array|ObjectConfigInterface $options An associative array of configuration options or a ObjectConfigInterface instance.
     */
    public function __construct($options = array())
    {
        $this->merge($options);
    }

    /**
     * Get a new instance
     *
     * @return ObjectConfigInterface
     */
    public static function getInstance()
    {
        $instance = new static(array());
        return $instance;
    }

    /**
     * Retrieve a configuration option
     *
     * If the option does not exist return the default.
     *
     * @param string  $name
     * @param mixed   $default
     * @return mixed
     */
    public function get($name, $default = null)
    {
        $result = $default;
        if(isset($this->__options[$name]) || array_key_exists($name, $this->__options)) {
            $result = $this->__options[$name];
        }

        return $result;
    }

    /**
     * Set a configuration option
     *
     * @param  string $name
     * @param  mixed  $value
     * @return ObjectConfig
     */
    public function set($name, $value)
    {
        if (is_array($value)) {
            $this->__options[$name] = $this->getInstance()->merge($value);
        } else {
            $this->__options[$name] = $value;
        }

        return $this;
    }

    /**
     * Check if a configuration option exists
     *
     * @param   string  $name The configuration option name.
     * @return  boolean
     */
    public function has($name)
    {
        return isset($this->__options[$name]);
    }

    /**
     * Remove a configuration option  by name
     *
     * @param   string $name The configuration option name.
     * @return  ObjectConfig
     */
    public function remove( $name )
    {
        $key = false;
        if(!isset($this->__options[$name])) {
            $key = array_search($name, $this->__options);
        } else {
            $key = $name;
        }

        if($key !== false) {
            unset($this->__options[$key]);
        }<commit_msg>#128 Make a strict search<commit_after><?php
/**
 * Kodekit - http://timble.net/kodekit
 *
 * @copyright   Copyright (C) 2007 - 2016 <NAME> and Timble CVBA. (http://www.timble.net)
 * @license     MPL v2.0 <https://www.mozilla.org/en-US/MPL/2.0>
 * @link        https://github.com/timble/kodekit for the canonical source repository
 */

namespace Kodekit\Library;

/**
 * ObjectConfig
 *
 * ObjectConfig provides a property based interface to an array.
 *
 * @author  <NAME> <https://github.com/johanjanssens>
 * @package Kodekit\Library\Object\Config
 */
class ObjectConfig implements ObjectConfigInterface
{
    /**
     * The configuration options
     *
     * @var array
     */
    private $__options = array();

    /**
     * Constructor.
     *
     * @param  array|ObjectConfigInterface $options An associative array of configuration options or a ObjectConfigInterface instance.
     */
    public function __construct($options = array())
    {
        $this->merge($options);
    }

    /**
     * Get a new instance
     *
     * @return ObjectConfigInterface
     */
    public static function getInstance()
    {
        $instance = new static(array());
        return $instance;
    }

    /**
     * Retrieve a configuration option
     *
     * If the option does not exist return the default.
     *
     * @param string  $name
     * @param mixed   $default
     * @return mixed
     */
    public function get($name, $default = null)
    {
        $result = $default;
        if(isset($this->__options[$name]) || array_key_exists($name, $this->__options)) {
            $result = $this->__options[$name];
        }

        return $result;
    }

    /**
     * Set a configuration option
     *
     * @param  string $name
     * @param  mixed  $value
     * @return ObjectConfig
     */
    public function set($name, $value)
    {
        if (is_array($value)) {
            $this->__options[$name] = $this->getInstance()->merge($value);
        } else {
            $this->__options[$name] = $value;
        }

        return $this;
    }

    /**
     * Check if a configuration option exists
     *
     * @param   string  $name The configuration option name.
     * @return  boolean
     */
    public function has($name)
    {
        return isset($this->__options[$name]);
    }

    /**
     * Remove a configuration option  by name
     *
     * @param   string $name The configuration option name.
     * @return  ObjectConfig
     */
    public function remove( $name )
    {
        $key = false;
        if(!isset($this->__options[$name])) {
            $key = array_search($name, $this->__options, true);
        } else {
            $key = $name;
        }

        if($key !== false) {
            unset($this->__options[$key]);
        }
{'fraction_non_alphanumeric': 0.1319118178532707, 'fraction_numerical': 0.004878930249367546, 'mean_word_length': 2.0179934569247546, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 35, 'https://': 6, 'lorem ipsum': 0, 'www.': 4, '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': '7032113', 'n_tokens_mistral': 1638, 'n_tokens_neox': 1596, 'n_words': 401}