<commit_before><?php

class OutletConfig {
	public $conf;

	private $con;

	private $entities;

	function __construct (array $conf) {
		// validate config
		if (!isset($conf['connection'])) throw new OutletConfigException('Element [connection] not found in configuration');
		if (!isset($conf['connection']['dsn'])) throw new OutletConfigException('Element [connection][dsn] not found in configuration');
		if (!isset($conf['connection']['dialect'])) throw new OutletConfigException('Element [connection][dialect] not found in configuration');
		if (!isset($conf['classes'])) throw new OutletConfigException('Element [classes] missing in configuration');

		$this->conf = $conf;
	}	

	/**
	 * @return OutletConnection
	 */
	function getConnection () {
		if (!$this->con) {
			$conn = $this->conf['connection'];

			$dsn = $conn['dsn'];
			$driver = substr($dsn, 0, strpos($dsn, ':'));

			$pdo = new PDO($conn['dsn'], @$conn['username'], @$conn['password']);
			$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

			$this->con = new OutletConnection($pdo, $driver, $conn['dialect']);
		} 
		return $this->con;
	}

	/**
	 * @return array
	 */
	function getEntities () {
		if (is_null($this->entities)) {
			$this->entities = array();
			foreach ($this->conf['classes'] as $key=>$cls) {
				$this->entities[$key] = new OutletEntityConfig($this, $key, $cls);
			}
		}
		return $this->entities;
	}

	/**
	 * @param string $cls
	 * @return OutletEntityConfig
	 */
	function getEntity ($cls) {
		if (is_null($this->entities)) $this->getEntities();

		if (!isset($this->entities[$cls])) throw new OutletException('Entity ['.$cls.'] has not been defined in the configuration');

		return $this->entities[$cls];
	}
	
	function useGettersAndSetters () {
		return isset($this->conf['useGettersAndSetters']) ? $this->conf['useGettersAndSetters'] : false;
	}
}

class OutletEntityConfig {
	private $data;

	private $config;

	private $clazz;
	private $props;
	private $associations;
	
	private $sequenceName = '';
	
	private $useGettersAndSetters;

	function __construct (OutletConfig $config, $entity, array $conf) {
		$this->config = $config;

		if (!isset($conf['table'])) throw new OutletConfigException('Mapping for entity ['.$entity.'] is missing element [table]');
		if (!isset($conf['props'])) throw new OutletConfigException('Mapping for entity ['.$entity.'] is missing element [props]');

		// i need to leave this for for the outletgen script
		//if (!class_exists($entity)) throw new OutletConfigException('Class does not exist for mapped entity ['.$entity.']');

		// validate that there's a pk
		foreach ($conf['props'] as $p=>$f) {
			if (@$f[2]['pk']) {<commit_msg>- Added missing OutletConfig::addEntities function<commit_after><?php

class OutletConfig {
	public $conf;

	private $con;

	private $entities;

	function __construct (array $conf) {
		// validate config
		if (!isset($conf['connection'])) throw new OutletConfigException('Element [connection] not found in configuration');
		if (!isset($conf['connection']['dsn'])) throw new OutletConfigException('Element [connection][dsn] not found in configuration');
		if (!isset($conf['connection']['dialect'])) throw new OutletConfigException('Element [connection][dialect] not found in configuration');
		if (!isset($conf['classes'])) throw new OutletConfigException('Element [classes] missing in configuration');

		$this->conf = $conf;
	}	

	/**
	 * @return OutletConnection
	 */
	function getConnection () {
		if (!$this->con) {
			$conn = $this->conf['connection'];

			$dsn = $conn['dsn'];
			$driver = substr($dsn, 0, strpos($dsn, ':'));

			$pdo = new PDO($conn['dsn'], @$conn['username'], @$conn['password']);
			$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

			$this->con = new OutletConnection($pdo, $driver, $conn['dialect']);
		} 
		return $this->con;
	}

	/**
	 * @return array
	 */
	function getEntities () {
		if (is_null($this->entities)) {
			$this->entities = array();
			foreach ($this->conf['classes'] as $key=>$cls) {
				$this->entities[$key] = new OutletEntityConfig($this, $key, $cls);
			}
		}
		return $this->entities;
	}

	/**
	 * @param string $cls
	 * @return OutletEntityConfig
	 */
	function getEntity ($cls) {
		if (is_null($this->entities)) $this->getEntities();

		if (!isset($this->entities[$cls])) throw new OutletException('Entity ['.$cls.'] has not been defined in the configuration');

		return $this->entities[$cls];
	}
	
	function useGettersAndSetters () {
		return isset($this->conf['useGettersAndSetters']) ? $this->conf['useGettersAndSetters'] : false;
	}

  function addEntities($entities) {
    foreach ($entities as $key=>$cls) {
      $this->conf['classes'][$key] = $cls;
      $this->entities[$key] = new OutletEntityConfig($this, $key, $cls);
    }
    OutletMapper::$conf = &$this->conf['classes'];
    return $this->entities;
  }
}

class OutletEntityConfig {
	private $data;

	private $config;

	private $clazz;
	private $props;
	private $associations;
	
	private $sequenceName = '';
	
	private $useGettersAndSetters;

	function __construct (OutletConfig $config, $entity, array $conf) {
		$this->config = $config;

		if (!isset($conf['table'])) throw new OutletConfigException('Mapping for entity ['.$entity.'] is missing element [table]');
		if (!isset($conf['props'])) throw new OutletConfigException('Mapping for entity ['.$entity.'] is missing element [props]');

		// i need to leave this for for the outletgen script
		//if (!class_exists($entity)) throw new OutletConfigException('Class does not exist for mapped entity ['.$entity.']');

		// validate that there's a pk
		foreach ($conf['props'] as $p=>$f) {
			if (@$f[2]['pk']) {
{'fraction_non_alphanumeric': 0.18095405738426334, 'fraction_numerical': 0.0007041013906002464, 'mean_word_length': 4.827692307692308, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 48, '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': '969696', 'n_tokens_mistral': 1906, 'n_tokens_neox': 1772, 'n_words': 455}