<commit_before><?php

namespace Mva\Mongo;

use Mva,
	Nette,
	MongoClient,
	MongoUpdateBatch,
	MongoInsertBatch;

/**
 * MongoDB context.
 *
 * @author <NAME>
 */
class Context extends Nette\Object
{

	/** @var \MongoDB */
	private $database;

	public function __construct($name, MongoClient $connection)
	{
		$this->database = $connection->selectDB($name);
	}

	/**
	 * Returns collection
	 * @param string Collection name
	 * @return Collection
	 */
	public function collection($name)
	{
		return new Mva\Mongo\Collection($name, $this->database);
	}

	/** @return MongoUpdateBatch */
	public function batchUpdate($name)
	{
		if (class_exists('\\MongoUpdateBatch')) {
			return new MongoUpdateBatch($this->database->selectCollection($name));
		}

		throw new NotSupportedException('Batch update is not available in your version of the PHP Mongo extension. Update it to version 1.5.0 or newer.');
	}

	/** @return MongoInsertBatch */
	public function batchInsert($name)
	{
		if (class_exists('\\MongoInsertBatch')) {
			return new MongoInsertBatch($this->database->selectCollection($name));
		}

		throw new NotSupportedException('Batch insert is not available in your version of the PHP Mongo extension. Update it to version 1.5.0 or newer.');
	}

}<commit_msg>Context: added batchDelete and database getter<commit_after><?php

namespace Mva\Mongo;

use Mva,
	Nette,
	MongoDB,
	MongoClient,
	MongoDeleteBatch,
	MongoUpdateBatch,
	MongoInsertBatch;

/**
 * MongoDB context.
 *
 * @author <NAME>
 */
class Context extends Nette\Object
{

	/** @var \MongoDB */
	private $database;

	public function __construct($name, MongoClient $connection)
	{
		$this->database = $connection->selectDB($name);
	}

	/**
	 * Returns collection
	 * @param string Collection name
	 * @return Collection
	 */
	public function collection($name)
	{
		return new Mva\Mongo\Collection($name, $this->database);
	}

	/**
	 * Returns selected database
	 * @return MongoDB
	 */
	public function getDatabase()
	{
		return $this->database;
	}

	/** @return MongoUpdateBatch */
	public function batchUpdate($name)
	{
		if (class_exists('\\MongoUpdateBatch')) {
			return new MongoUpdateBatch($this->database->selectCollection($name));
		}

		throw new NotSupportedException('Update batch is not available in your version of the PHP Mongo extension. Update it to version 1.5.0 or newer.');
	}

	/** @return MongoInsertBatch */
	public function batchInsert($name)
	{
		if (class_exists('\\MongoInsertBatch')) {
			return new MongoInsertBatch($this->database->selectCollection($name));
		}

		throw new NotSupportedException('Insert batch is not available in your version of the PHP Mongo extension. Update it to version 1.5.0 or newer.');
	}

	public function batchDelete($name)
	{
		if (class_exists('\\MongoDeleteBatch')) {
			return new MongoDeleteBatch($this->database->selectCollection($name));
		}

		throw new NotSupportedException('Delete batch is not available in your version of the PHP Mongo extension. Update it to version 1.5.0 or newer.');
	}

}
{'fraction_non_alphanumeric': 0.12429752066115703, 'fraction_numerical': 0.0049586776859504135, 'mean_word_length': 4.2717770034843205, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 22, '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': '4408366', 'n_tokens_mistral': 971, 'n_tokens_neox': 894, 'n_words': 261}