<commit_before><?php
/*
 * This file is part of the Pomm's Foundation package.
 *
 * (c) 2014 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace PommProject\Foundation\Session;

use PommProject\Foundation\Exception\ConnectionException;
use PommProject\Foundation\Exception\SqlException;
use PommProject\Foundation\Session\ConnectionConfigurator;
use PommProject\Foundation\Session\ResultHandler;

/**
 * Connection
 *
 * Manage connection through a resource handler.
 *
 * @package Foundation
 * @copyright 2014 <NAME>
 * @author <NAME>
 * @license X11 {@link http://opensource.org/licenses/mit-license.php}
 */
class Connection
{
    const CONNECTION_STATUS_NONE    = 0;
    const CONNECTION_STATUS_GOOD    = 1;
    const CONNECTION_STATUS_BAD     = 2;
    const ISOLATION_READ_COMMITTED  = "READ COMMITTED";  // default
    const ISOLATION_READ_REPEATABLE = "READ REPEATABLE"; // from Pg 9.1
    const ISOLATION_SERIALIZABLE    = "SERIALIZABLE";    // changes in 9.1
    const CONSTRAINTS_DEFERRED      = "DEFERRED";
    const CONSTRAINTS_IMMEDIATE     = "IMMEDIATE";       // default
    const ACCESS_MODE_READ_ONLY     = "READ ONLY";
    const ACCESS_MODE_READ_WRITE    = "READ WRITE";      // default

    protected $handler = null;
    protected $configurator;

    /**
     * __construct
     *
     * Constructor. Test if the given DSN is valid.
     *
     * @access public
     * @param  string $dsn
     * @param  array $configuration
     */
    public function __construct($dsn, array $configuration = [])
    {
        $this->configurator = new ConnectionConfigurator($dsn);
        $this->configurator->addConfiguration($configuration);<commit_msg>Fix #55 - Handling missing pgsql w/ appropriate error msg<commit_after><?php
/*
 * This file is part of the Pomm's Foundation package.
 *
 * (c) 2014 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace PommProject\Foundation\Session;

use PommProject\Foundation\Exception\ConnectionException;
use PommProject\Foundation\Exception\SqlException;
use PommProject\Foundation\Session\ConnectionConfigurator;
use PommProject\Foundation\Session\ResultHandler;

/**
 * Connection
 *
 * Manage connection through a resource handler.
 *
 * @package Foundation
 * @copyright 2014 <NAME>
 * @author <NAME>
 * @license X11 {@link http://opensource.org/licenses/mit-license.php}
 */
class Connection
{
    const CONNECTION_STATUS_NONE    = 0;
    const CONNECTION_STATUS_GOOD    = 1;
    const CONNECTION_STATUS_BAD     = 2;
    const ISOLATION_READ_COMMITTED  = "READ COMMITTED";  // default
    const ISOLATION_READ_REPEATABLE = "READ REPEATABLE"; // from Pg 9.1
    const ISOLATION_SERIALIZABLE    = "SERIALIZABLE";    // changes in 9.1
    const CONSTRAINTS_DEFERRED      = "DEFERRED";
    const CONSTRAINTS_IMMEDIATE     = "IMMEDIATE";       // default
    const ACCESS_MODE_READ_ONLY     = "READ ONLY";
    const ACCESS_MODE_READ_WRITE    = "READ WRITE";      // default

    protected $handler = null;
    protected $configurator;

    /**
     * __construct
     *
     * Constructor. Test if the given DSN is valid.
     *
     * @access public
     * @param  string $dsn
     * @param  array $configuration
     */
    public function __construct($dsn, array $configuration = [])
    {
        if (!function_exists('pg_connection_status')) {
            throw new \Exception("`pgsql` PHP extension's functions are unavailable in your environment, please make sure PostgreSQL support is enabled in PHP.");  
        }
        $this->configurator = new ConnectionConfigurator($dsn);
        $this->configurator->addConfiguration($configuration);
{'fraction_non_alphanumeric': 0.0981418476838524, 'fraction_numerical': 0.00942161737764983, 'mean_word_length': 3.265625, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, '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': '1538431', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1117, 'n_words': 303}