예제 #1
0
파일: MongoDb.php 프로젝트: 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;
 }
예제 #2
0
파일: Memcached.php 프로젝트: ksst/kf
 /**
  * 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;
 }