2 /** HTTP Client interface
6 namespace Doctrine\CouchDB\HTTP
;
9 * Basic couch DB connection handling class
11 * @license http://www.opensource.org/licenses/mit-license.php MIT
12 * @link www.doctrine-project.com
14 * @author Kore Nordmann <kore@arbitracker.org>
16 abstract class AbstractHTTPClient
implements Client
19 * CouchDB connection options
23 protected $options = array(
24 'host' => 'localhost',
36 * Construct a CouchDB connection
38 * Construct a CouchDB connection from basic connection parameters for one
43 * @param string $username
44 * @param string $password
48 * @return \Doctrine\CouchDB\HTTP\AbstractHTTPClient
50 public function __construct($host = 'localhost', $port = 5984, $username = null, $password = null, $ip = null , $ssl = false, $path = null, $timeout = 0.01)
52 $this->options
['host'] = (string) $host;
53 $this->options
['port'] = (int) $port;
54 $this->options
['ssl'] = $ssl;
55 $this->options
['username'] = $username;
56 $this->options
['password'] = $password;
57 $this->options
['path'] = $path;
58 $this->options
['timeout'] = (float) $timeout;
61 $this->options
['ip'] = gethostbyname($this->options
['host']);
63 $this->options
['ip'] = $ip;
70 * Set the value for an connection option. Throws an
71 * InvalidArgumentException for unknown options.
73 * @param string $option
76 * @throws \InvalidArgumentException
80 public function setOption( $option, $value )
85 $this->options
[$option] = (bool) $value;
91 $this->options
[$option] = $value;
95 throw new \
InvalidArgumentException( "Unknown option $option." );
100 * Get the connection options.
104 public function getOptions()
106 return $this->options
;