<commit_before><?php

namespace Gestalt;

use Closure;
use ArrayAccess;
use Traversable;
use Gestalt\Util\Observable;
use Gestalt\Loaders\LoaderInterface;

class Configuration extends Observable implements ArrayAccess
{
    /**
     * The configuration items.
     *
     * @var array
     */
    protected $items;

    /**
     * The original configuration items.
     *
     * @var array
     */
    protected $original;

    /**
     * Create a new Configuration instance.
     *
     * @param mixed $items
     */
    public function __construct($items = [])
    {
        $this->items = $this->getItemsAsArray($items);

        $this->original = $this->items;
    }

    /**
     * Create a new Configuration with the given loader.
     *
     * @param  \Gestalt\Loaders\LoaderInterface|\Closure $loader
     * @return \Gestalt\Collection
     */
    public static function load($loader)
    {
        if ($loader instanceof Closure) {
            return new self($loader());
        } elseif ($loader instanceof LoaderInterface) {
            return new self($loader->load());
        }
    }

    /**
     * Create a Configuration instance from a LoaderInterface's `load` method.
     *
     * @deprecated 1.0.0 Replaced with more flexible `load` method.
     * @param  \Gestalt\Loaders\LoaderInterface $loader<commit_msg>Use late static binding on load method.<commit_after><?php

namespace Gestalt;

use Closure;
use ArrayAccess;
use Traversable;
use Gestalt\Util\Observable;
use Gestalt\Loaders\LoaderInterface;

class Configuration extends Observable implements ArrayAccess
{
    /**
     * The configuration items.
     *
     * @var array
     */
    protected $items;

    /**
     * The original configuration items.
     *
     * @var array
     */
    protected $original;

    /**
     * Create a new Configuration instance.
     *
     * @param mixed $items
     */
    public function __construct($items = [])
    {
        $this->items = $this->getItemsAsArray($items);

        $this->original = $this->items;
    }

    /**
     * Create a new Configuration with the given loader.
     *
     * @param  \Gestalt\Loaders\LoaderInterface|\Closure $loader
     * @return \Gestalt\Collection
     */
    public static function load($loader)
    {
        if ($loader instanceof Closure) {
            return new static($loader());
        } elseif ($loader instanceof LoaderInterface) {
            return new static($loader->load());
        }
    }

    /**
     * Create a Configuration instance from a LoaderInterface's `load` method.
     *
     * @deprecated 1.0.0 Replaced with more flexible `load` method.
     * @param  \Gestalt\Loaders\LoaderInterface $loader
{'fraction_non_alphanumeric': 0.11123511904761904, 'fraction_numerical': 0.002232142857142857, 'mean_word_length': 2.295343137254902, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '4528001', 'n_tokens_mistral': 761, 'n_tokens_neox': 738, 'n_words': 205}