<commit_before><?php

/**
 * This file is part of the Nextras\Orm library.
 * @license    MIT
 * @link       https://github.com/nextras/orm
 */

namespace Nextras\Orm\Model;

use Nette\Object;
use Nextras\Orm\InvalidArgumentException;
use Nextras\Orm\LogicException;
use Nextras\Orm\Repository\IRepository;


class Model extends Object implements IModel
{
	/** @var array of callbacks with (IEntity[] $persisted, IEntity $removed) arguments */
	public $onFlush = [];

	/** @var IRepositoryLoader */
	private $loader;

	/** @var MetadataStorage */
	private $metadataStorage;

	/** @var array */
	private $configuration;


	/**
	 * Creates repository list configuration.
	 * @param  IRepository[] $repositories
	 * @return array
	 */
	public static function getConfiguration(array $repositories)
	{
		$config = [[], [], []];
		foreach ($repositories as $name => $repository) {
			$className = is_object($repository) ? get_class($repository) : $repository;
			$config[0][$className] = TRUE;
			$config[1][$name] = $className;
			foreach ($repository::getEntityClassNames() as $entityClassName) {
				$config[2][$entityClassName] = $className;
			}
		}
		return $config;
	}


	public function __construct(array $configuration, IRepositoryLoader $repositoryLoader, MetadataStorage $metadataStorage)
	{
		$this->loader = $repositoryLoader;
		$this->metadataStorage = $metadataStorage;
		$this->configuration = $configuration;
	}


	public function hasRepositoryByName($name)
	{
		return isset($this->configuration[1][$name]);
	}


	public function getRepositoryByName($name)
	{
		if (!isset($this->configuration[1][$name])) {
			throw new InvalidArgumentException("Repository '$name' does not exist.'");
		}
		return $this->getRepository($this->configuration[1][$name]);
	}


	public function hasRepository($className)
	{
		return isset($this->configuration[0][$className]);
	}

<commit_msg>typo: fix model exception message<commit_after><?php

/**
 * This file is part of the Nextras\Orm library.
 * @license    MIT
 * @link       https://github.com/nextras/orm
 */

namespace Nextras\Orm\Model;

use Nette\Object;
use Nextras\Orm\InvalidArgumentException;
use Nextras\Orm\LogicException;
use Nextras\Orm\Repository\IRepository;


class Model extends Object implements IModel
{
	/** @var array of callbacks with (IEntity[] $persisted, IEntity $removed) arguments */
	public $onFlush = [];

	/** @var IRepositoryLoader */
	private $loader;

	/** @var MetadataStorage */
	private $metadataStorage;

	/** @var array */
	private $configuration;


	/**
	 * Creates repository list configuration.
	 * @param  IRepository[] $repositories
	 * @return array
	 */
	public static function getConfiguration(array $repositories)
	{
		$config = [[], [], []];
		foreach ($repositories as $name => $repository) {
			$className = is_object($repository) ? get_class($repository) : $repository;
			$config[0][$className] = TRUE;
			$config[1][$name] = $className;
			foreach ($repository::getEntityClassNames() as $entityClassName) {
				$config[2][$entityClassName] = $className;
			}
		}
		return $config;
	}


	public function __construct(array $configuration, IRepositoryLoader $repositoryLoader, MetadataStorage $metadataStorage)
	{
		$this->loader = $repositoryLoader;
		$this->metadataStorage = $metadataStorage;
		$this->configuration = $configuration;
	}


	public function hasRepositoryByName($name)
	{
		return isset($this->configuration[1][$name]);
	}


	public function getRepositoryByName($name)
	{
		if (!isset($this->configuration[1][$name])) {
			throw new InvalidArgumentException("Repository '$name' does not exist.");
		}
		return $this->getRepository($this->configuration[1][$name]);
	}


	public function hasRepository($className)
	{
		return isset($this->configuration[0][$className]);
	}


{'fraction_non_alphanumeric': 0.14515703351807865, 'fraction_numerical': 0.003694906307732911, 'mean_word_length': 4.733736762481089, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 2, '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': '1160030', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1124, 'n_words': 258}