Example #1
0
 public function testExpand()
 {
     $flatConfig = array('one' => 'hello world', 'two.twoA.0' => 'one', 'two.twoA.1' => 'two', 'two.twoA.2' => 'three', 'two.other' => 'value');
     $expected = array('one' => 'hello world', 'two' => array('twoA' => array('one', 'two', 'three'), 'other' => 'value'));
     $this->assertEquals($expected, Config::expand($flatConfig));
 }
Example #2
0
 /**
  * Get connection, create if required
  *
  * @return \PDO
  */
 protected function getConnection()
 {
     if (!$this->connection instanceof \PDO) {
         if (!isset($this->dbConfig['host'])) {
             throw new \InvalidArgumentException('Missing host config param');
         }
         $dsn = "mysql:host={$this->dbConfig['host']}";
         if (isset($this->dbConfig['port'])) {
             $dsn .= ";port={$this->dbConfig['port']}";
         }
         $timeout = filter_var(Config::get($this->dbConfig, 'timeout'), FILTER_VALIDATE_INT, array('options' => array('default' => 2, 'min_range' => 0, 'max_range' => 120)));
         $options = array(\PDO::ATTR_TIMEOUT => $timeout, \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC);
         $this->connection = new \PDO($dsn, Config::get($this->dbConfig, 'username', ''), Config::get($this->dbConfig, 'password', ''), $options);
     }
     return $this->connection;
 }