for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace AudioManager\Request;
/**
* Class CurlRequest
* @package AudioManager\Request
*/
class CurlRequest implements RequestInterface
{
* Curl handle
* @var resource
private $handle;
* Constructor
* Create curl handle
* @param $url
public function __construct($url = null)
$this->handle = curl_init($url);
}
* Close connection
public function __destruct()
$this->close();
* @return bool
public function setUrl($url)
return $this->setOption(CURLOPT_URL, $url);
* Set option
* @param string $name
* @param mixed $value
* @return $this
public function setOption($name, $value)
curl_setopt($this->handle, $name, $value);
return $this;
* Execute request
* @return mixed
public function execute()
return curl_exec($this->handle);
* Get info from request
* @param int $opt
public function getInfo($opt = null)
if ($opt !== null) {
return curl_getinfo($this->handle, $opt);
return curl_getinfo($this->handle);
* Get error message
public function getError()
return curl_error($this->handle);
* Close http connection
* @return void
public function close()
curl_close($this->handle);