Ejemplo n.º 1
0
Archivo: MongoDb.php Proyecto: ksst/kf
 public function setOption($key, $value)
 {
     switch ($key) {
         case 'database':
             $database = (string) $value;
             if ($database === '') {
                 throw new \InvalidArgumentException('Database can not be empty.');
             }
             $this->options['database'] = $database;
             break;
         case 'collection':
             $database = (string) $value;
             if ($database === '') {
                 throw new \InvalidArgumentException('Collection can not be empty.');
             }
             $this->options['collection'] = $database;
             break;
         default:
             // maybe the option is known on the parent class, otherwise will throw excetion
             parent::setOption($key, $value);
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * Sets a single option.
  *
  * @param string Key.
  * @param mixed Value.
  *
  * @return bool True, if successfull.
  */
 public function setOption($key, $value)
 {
     switch ($key) {
         case 'useConnection':
             $value = (string) $value;
             if ($value === '') {
                 throw new \InvalidArgumentException('useConnection options can not be empty.');
             }
             $this->options['useConnection'] = $value;
             break;
         case 'connection':
             $connection = (array) $value;
             if (is_array($connection) === false) {
                 throw new \InvalidArgumentException('Connection option must be array.');
             }
             $this->options['connection'] = $connection;
             break;
         default:
             // maybe the option is known on the parent class, otherwise will throw excetion
             parent::setOption($key, $value);
     }
     return true;
 }