<commit_before><?php namespace Ordercloud\Support;

use Illuminate\Container\Container;
use Ordercloud\Ordercloud;
use Ordercloud\Support\CommandBus\IlluminateCommandHandlerTranslator;
use Ordercloud\Support\Http\GuzzleClient;

class QuickStart
{
    /** @var Container */
    private $container;
    /**
     * @var array
     */
    private $config;

    /**
     * @param Container $container
     * @param array     $config
     */
    public function __construct(Container $container, array $config)
    {
        $this->config = $config;
        $self = $this;
        $container->singleton('Ordercloud\Ordercloud');
        $container->singleton('Ordercloud\Support\Parser');
        $container->singleton('Ordercloud\Support\Http\UrlParameteriser', 'Ordercloud\Support\Http\LeagueUrlParameteriser');
        $container->singleton('Ordercloud\Support\CommandBus\CommandBus', 'Ordercloud\Support\CommandBus\ExecutingCommandBus');
        $container->singleton('Ordercloud\Support\CommandBus\CommandHandlerTranslator', function() use ($container) {
            return new IlluminateCommandHandlerTranslator($container);
        });
        $container->singleton('Ordercloud\Support\Http\Client', function() use ($self) {
            return new GuzzleClient(
                $self->getConfig('http.base_url'),
                $self->getConfig('credentials.username'),
                $self->getConfig('credentials.password'),
                $self->getConfig('credentials.organisation_token')
            );
        });
        $this->container = $container;
    }

    /**
     * Create a new instance of ordercloud
     *
     * @param array $config
     *
     * @return Ordercloud
     */
    public static function create(array $config)
    {
        $container = new Container();

        $quickStart = new static($container, $config);

        return $quickStart->make();
    }

    /**
     * Creates an instance of Ordercloud.
     *
     * @return Ordercloud
     */
    public function make()
    {
        return $this->container->make('Ordercloud\Ordercloud');
    }

    /**
     * @param string     $key
     * @param mixed $default
     *
     * @return mixed
     */
    private function getConfig($key, $default = null)
    {
        if (array_key_exists($key, $this->config)) {
            return $this->config[$key];
        }

        return $this->getDotNotationConfig($key, $default, $this->config);
    }

    /**
     * Retreive a nested multidimentional array value.
     *
     * @param string     $key
     * @param mixed $default
     *
     * @return mixed
     */
    private function getDotNotationConfig($key, $default)
    {
        $config = $this->config;

        foreach (explode('.', $key) as $segment) {
            if ( ! is_array($config) || ! array_key_exists($segment, $config)) {
                return $default;
            }
            $config = $config[$segment];
        }

        return $config;
    }<commit_msg>Removed unused code<commit_after><?php namespace Ordercloud\Support;

use Illuminate\Container\Container;
use Ordercloud\Ordercloud;
use Ordercloud\Support\CommandBus\IlluminateCommandHandlerTranslator;
use Ordercloud\Support\Http\GuzzleClient;

class QuickStart
{
    /** @var Container */
    private $container;
    /**
     * @var array
     */
    private $config;

    /**
     * @param Container $container
     * @param array     $config
     */
    public function __construct(Container $container, array $config)
    {
        $this->config = $config;
        $self = $this;
        $container->singleton('Ordercloud\Ordercloud');
        $container->singleton('Ordercloud\Support\Parser');
        $container->singleton('Ordercloud\Support\Http\UrlParameteriser', 'Ordercloud\Support\Http\LeagueUrlParameteriser');
        $container->singleton('Ordercloud\Support\CommandBus\CommandBus', 'Ordercloud\Support\CommandBus\ExecutingCommandBus');
        $container->singleton('Ordercloud\Support\CommandBus\CommandHandlerTranslator', function() use ($container) {
            return new IlluminateCommandHandlerTranslator($container);
        });
        $container->singleton('Ordercloud\Support\Http\Client', function() use ($self) {
            return new GuzzleClient(
                $self->getConfig('http.base_url'),
                $self->getConfig('credentials.username'),
                $self->getConfig('credentials.password'),
                $self->getConfig('credentials.organisation_token')
            );
        });
        $this->container = $container;
    }

    /**
     * Create a new instance of ordercloud
     *
     * @param array $config
     *
     * @return Ordercloud
     */
    public static function create(array $config)
    {
        $container = new Container();

        $quickStart = new static($container, $config);

        return $quickStart->make();
    }

    /**
     * Creates an instance of Ordercloud.
     *
     * @return Ordercloud
     */
    public function make()
    {
        return $this->container->make('Ordercloud\Ordercloud');
    }

    /**
     * @param string     $key
     * @param mixed $default
     *
     * @return mixed
     */
    private function getConfig($key, $default = null)
    {
        if (array_key_exists($key, $this->config)) {
            return $this->config[$key];
        }

        return $this->getDotNotationConfig($key, $default);
    }

    /**
     * Retreive a nested multidimentional array value.
     *
     * @param string     $key
     * @param mixed $default
     *
     * @return mixed
     */
    private function getDotNotationConfig($key, $default)
    {
        $config = $this->config;

        foreach (explode('.', $key) as $segment) {
            if ( ! is_array($config) || ! array_key_exists($segment, $config)) {
                return $default;
            }
            $config = $config[$segment];
        }

        return $config;
    }
{'fraction_non_alphanumeric': 0.13054477989542926, 'fraction_numerical': 0.0, 'mean_word_length': 2.31841074426413, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 42, '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': '5907993', 'n_tokens_mistral': 1633, 'n_tokens_neox': 1607, 'n_words': 315}