public function setOption($opt, $val = null)
{
// If an array of options is passed.
if (is_array($opt)) {
// Set the cURL options from the array.
curl_setopt_array($this->curl, $opt);
// Set the protected property to the cURL options.
foreach ($opt as $k => $v) {
$this->options[$k] = $v;
}
// Else, set the single option.
} else {
curl_setopt($this->curl, $opt, $val);
$this->options[$opt] = $val;
}
return $this;
}
public function testSetAndGetOptions() { $c = new Curl('http://www.popphp.org/version', array(CURLOPT_RETURNTRANSFER => true)); $c->setOption(CURLOPT_HEADER, false); $this->assertEquals(1, $c->getOption(CURLOPT_RETURNTRANSFER)); $this->assertEquals(0, $c->getOption(CURLOPT_HEADER)); }