<commit_before><?php

namespace Demand\Potato;

/**
 * Class ClientManager
 * @package Demand\Potato
 *
 * A singleton client manager when running without dependency injection.
 */
class ClientManager
{
    /** @var array */
    private $defaults = array(
        'name' => null,
        'uri' => 'http://127.0.0.1:8091',
        'bucket' => 'default',
        'password' => '',
        'username' => '',
        'class' => 'Demand\Potato\Document',
        'persist' => false,
        'connect' => true,
        'transcoder' => 'json',
        'environment' => 'development'
    );
    /** @var array  */
    private $clients= array();

    /**
     * Return a singleton instance of this class
     * @return ClientManager
     */
    public static function getInstance()
    {
        static $instance = null;
        if (null === $instance) {
            $instance = new static();
        }
        return $instance;
    }

    /**
     * @param array $defaults
     */
    public function setDefaults($defaults = array())
    {
        $this->defaults = array_merge($this->defaults,$defaults);
    }

    public function getClient($name, $options = array())
    {
        // make sure our arg is valid
        if (!is_string($name))
            throw new \InvalidArgumentException('$name must be specified and a string.');
        // if we have it, return it
        if (array_key_exists($name,$this->clients)) {
            return $this->clients[$name];
        }
        // looks like we need to make the connection
        $config = $options + $this->defaults;
        // make sure the name we pass to client is the same as the one we will use.
        if ($config['name'] != $name) $config['name'] = $name;
        $this->clients['name'] = new Client($config);
        return $this->clients['name'];
    }

    /**
     * Prevent instantiation directly from other classes
     */
    protected function __construct()
    {

    }

    /**
     * Private clone method to prevent cloning of the instance of the
     * *Singleton* instance.
     *
     * @return void
     */<commit_msg>default a non-specified bucket to the default bucket.<commit_after><?php

namespace Demand\Potato;

/**
 * Class ClientManager
 * @package Demand\Potato
 *
 * A singleton client manager when running without dependency injection.
 */
class ClientManager
{
    /** @var array */
    private $defaults = array(
        'name' => null,
        'uri' => 'http://127.0.0.1:8091',
        'bucket' => 'default',
        'password' => '',
        'username' => '',
        'class' => 'Demand\Potato\Document',
        'persist' => false,
        'connect' => true,
        'transcoder' => 'json',
        'environment' => 'development'
    );
    /** @var array  */
    private $clients= array();

    /**
     * Return a singleton instance of this class
     * @return ClientManager
     */
    public static function getInstance()
    {
        static $instance = null;
        if (null === $instance) {
            $instance = new static();
        }
        return $instance;
    }

    /**
     * @param array $defaults
     */
    public function setDefaults($defaults = array())
    {
        $this->defaults = array_merge($this->defaults,$defaults);
    }

    public function client($bucket = null, $options = array())
    {
        // if bucket is null, assume default
        if ($bucket === null) {
            $bucket = $this->defaults['bucket'];
        }
        // make sure our arg is valid
        if (!is_string($bucket)) {
            throw new \InvalidArgumentException('$name must be specified and a string.');
        }
        // if we have it, return it
        if (array_key_exists($bucket,$this->clients)) {
            return $this->clients[$bucket];
        }
        // looks like we need to make the connection
        $config = $options + $this->defaults;
        // make sure our bucket config is correct
        $config['bucket'] = $bucket;
        $this->clients['name'] = new Client($config);
        return $this->clients['name'];
    }

    /**
     * Prevent instantiation directly from other classes
     */
    protected function __construct()
    {

    }

    /**
     * Private clone method to prevent cloning of the instance of the
     * *Singleton* instance.
     *
     * @return void
     */
{'fraction_non_alphanumeric': 0.13899167437557816, 'fraction_numerical': 0.004625346901017576, 'mean_word_length': 2.0202513966480447, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '638750', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1177, 'n_words': 352}