<commit_before><?php
/**
 * Monga is a swift MongoDB Abstraction for PHP 5.3+
 *
 * @package    Monga
 * @version    1.0
 * @author     <NAME>
 * @license    MIT License
 * @copyright  2011 - 2012 <NAME>
 * @link       http://github.com/php-leop/monga
 */

namespace League\Monga;

use MongoClient;

class Connection
{
    /**
     * @var  Mongo  $connection  MongoDB Connection instance
     */
    protected $connection;

    /**
     * Establishes a MongoDB connection
     *
     * @param string $server  mongo dns
     * @param array  $options connection options
     */
    public function __construct($server = null, array $options = array())
    {
        if ($server instanceof MongoClient) {
            $this->connection = $server;
        } else {
            if (is_array($server)) {
                $options = $server;
                $server = null;
            }

            // Mimic the default mongo connect settings.
            if (! isset($options['connect'])) {
                $options['connect'] = true;
            }

            $this->connection = new MongoClient($server ?: 'mongodb://localhost:27017', $options);
        }
    }

    /**
     * Connection injector
     *
     * @param  object $connection MongoClient instance
     * @return object $this
     */
    public function setConnection(MongoClient $connection)
    {
        $this->connection = $connection;

        return $this;
    }

    /**
     * Retrieve the MongoConnection.
     *
     * @return object Mongo instance
     */
    public function getConnection()
    {
        return $this->connection;
    }

    /**
     * Connect to the database.
     *
     * @return boolean connection result
     */
    public function connect()
    {
        if (! $this->connection->connected) {
            return $this->connection->connect();
        }

        return true;
    }

    /**
     * Disconnect from a mongo database.
     *
     * @return boolean disconnect result
     */
    public function disconnect()
    {
        return $this->connection->close();
    }

    /**
     * Returns whether the connection is connection.<commit_msg>Replace another reference to the 'connected' property<commit_after><?php
/**
 * Monga is a swift MongoDB Abstraction for PHP 5.3+
 *
 * @package    Monga
 * @version    1.0
 * @author     <NAME>
 * @license    MIT License
 * @copyright  2011 - 2012 <NAME>
 * @link       http://github.com/php-leop/monga
 */

namespace League\Monga;

use MongoClient;

class Connection
{
    /**
     * @var  Mongo  $connection  MongoDB Connection instance
     */
    protected $connection;

    /**
     * Establishes a MongoDB connection
     *
     * @param string $server  mongo dns
     * @param array  $options connection options
     */
    public function __construct($server = null, array $options = array())
    {
        if ($server instanceof MongoClient) {
            $this->connection = $server;
        } else {
            if (is_array($server)) {
                $options = $server;
                $server = null;
            }

            // Mimic the default mongo connect settings.
            if (! isset($options['connect'])) {
                $options['connect'] = true;
            }

            $this->connection = new MongoClient($server ?: 'mongodb://localhost:27017', $options);
        }
    }

    /**
     * Connection injector
     *
     * @param  object $connection MongoClient instance
     * @return object $this
     */
    public function setConnection(MongoClient $connection)
    {
        $this->connection = $connection;

        return $this;
    }

    /**
     * Retrieve the MongoConnection.
     *
     * @return object Mongo instance
     */
    public function getConnection()
    {
        return $this->connection;
    }

    /**
     * Connect to the database.
     *
     * @return boolean connection result
     */
    public function connect()
    {
        if (empty($this->connection->getConnections()) {
            return $this->connection->connect();
        }

        return true;
    }

    /**
     * Disconnect from a mongo database.
     *
     * @return boolean disconnect result
     */
    public function disconnect()
    {
        return $this->connection->close();
    }

    /**
     * Returns whether the connection is connection.
{'fraction_non_alphanumeric': 0.11539349180706208, 'fraction_numerical': 0.007846757442880221, 'mean_word_length': 1.828981723237598, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 27, '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': '4128709', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1164, 'n_words': 315}