<commit_before><?php namespace Xavrsl\Ldap;

use Illuminate\Support\Manager;

class LdapManager {

	/**
	 * The active connection instances.
	 *
	 * @var array
	 */
	protected $connections = array();

	/**
	 * Get a Ldap connection instance.
	 *
	 * @param  string  $name
	 * @return Xavrsl\Ldap\Directory
	 */
	public function connection($name = null)
	{
		if ( ! isset($this->connections[$name]))
		{
			$this->connections[$name] = $this->createConnection($name);
		}

		return $this->connections[$name];
	}

	/**
	 * Create the given connection by name.
	 *
	 * @param  string  $name
	 * @return Xavrsl\Ldap\Directory
	 */
	protected function createConnection($name)
	{
		$config = $this->getConfig($name);

		// Ldap may optionally have a password. So, we will attempt to extract out
		// the password from the configuration. But one is not required so we'll
		// just use array_get to return null if one hasn't been set in config.
		$password = array_get($config, 'bindpwd'); 

		$connection = new Directory($config, $password);

		$connection->connect();
		$connection->bind();

		return $connection;
	}

	/**
	 * Get the configuration for a connection.
	 *
	 * @param  string  $name
	 * @return array
	 */
	protected function getConfig($name)
	{
		$name = $name ?: $this->getDefaultConnection();

		// To get the database connection configuration, we will just pull each of the
		// connection configurations and get the configurations for the given name.
		// If the configuration doesn't exist, we'll throw an exception and bail.
		// $connections = $this->app['config']['database.ldap'];
		$connections = \Config::get('ldap::config');

		if (is_null($config = array_get($connections, $name)))
		{
			throw new \InvalidArgumentException("Ldap [$name] not configured.");
		}

		return $config;
	}

	/**
	 * Get the default connection name.
	 *
	 * @return string
	 */
	protected function getDefaultConnection()
	{
		return 'default';
	}

	/**
	 * Dynamically pass methods to the default connection.
	 *
	 * @param  string  $method
	 * @param  array   $parameters
	 * @return mixed
	 */
	public function __call($method, $parameters)
	{<commit_msg>Change the way we access config, used to work in first release of laravel 4<commit_after><?php namespace Xavrsl\Ldap;

use Illuminate\Support\Manager;

class LdapManager {

	/**
	 * The active connection instances.
	 *
	 * @var array
	 */
	protected $connections = array();

	/**
	 * Get a Ldap connection instance.
	 *
	 * @param  string  $name
	 * @return Xavrsl\Ldap\Directory
	 */
	public function connection($name = null)
	{
		if ( ! isset($this->connections[$name]))
		{
			$this->connections[$name] = $this->createConnection($name);
		}

		return $this->connections[$name];
	}

	/**
	 * Create the given connection by name.
	 *
	 * @param  string  $name
	 * @return Xavrsl\Ldap\Directory
	 */
	protected function createConnection($name)
	{
		$config = $this->getConfig($name);

		// Ldap may optionally have a password. So, we will attempt to extract out
		// the password from the configuration. But one is not required so we'll
		// just use array_get to return null if one hasn't been set in config.
		$password = array_get($config, 'bindpwd'); 

		$connection = new Directory($config, $password);

		$connection->connect();
		$connection->bind();

		return $connection;
	}

	/**
	 * Get the configuration for a connection.
	 *
	 * @param  string  $name
	 * @return array
	 */
	protected function getConfig($name)
	{
		$name = $name ?: $this->getDefaultConnection();

		// To get the database connection configuration, we will just pull each of the
		// connection configurations and get the configurations for the given name.
		// If the configuration doesn't exist, we'll throw an exception and bail.
		// $connections = $this->app['config']['database.ldap'];
		$connections = \Config::get('ldap::'.$name);

		if (is_null($connections))
		{
			throw new \InvalidArgumentException("Ldap [$name] not configured.");
		}

		return $connections;
	}

	/**
	 * Get the default connection name.
	 *
	 * @return string
	 */
	protected function getDefaultConnection()
	{
		return 'default';
	}

	/**
	 * Dynamically pass methods to the default connection.
	 *
	 * @param  string  $method
	 * @param  array   $parameters
	 * @return mixed
	 */
	public function __call($method, $parameters)
	{
{'fraction_non_alphanumeric': 0.13135495744191397, 'fraction_numerical': 0.00023004370830457787, 'mean_word_length': 3.423194303153611, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '5606288', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1271, 'n_words': 410}