easy-curl update
This commit is contained in:
parent
a37287a3a6
commit
8eefa537c0
@ -10,7 +10,7 @@ class Collection
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts current object to array
|
* Converts current object to array
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function toArray()
|
public function toArray()
|
||||||
@ -20,10 +20,9 @@ class Collection
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets value
|
* Sets value
|
||||||
*
|
*
|
||||||
* @param mixed $key Key
|
* @param mixed $key Key
|
||||||
* @param mixed $value Value
|
* @param mixed $value Value
|
||||||
*
|
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function set($key, $value = null)
|
public function set($key, $value = null)
|
||||||
@ -40,9 +39,8 @@ class Collection
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if key does exist
|
* Checks if key does exist
|
||||||
*
|
*
|
||||||
* @param mixed $key Key
|
* @param mixed $key Key
|
||||||
*
|
|
||||||
* @return bool TRUE if exists, FALSE otherwise
|
* @return bool TRUE if exists, FALSE otherwise
|
||||||
*/
|
*/
|
||||||
public function has($key)
|
public function has($key)
|
||||||
@ -51,10 +49,10 @@ class Collection
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns value of $key, throws Exception if does not exist
|
* Returns value of $key
|
||||||
*
|
*
|
||||||
* @param mixed $key Key
|
* @param mixed $key Key
|
||||||
*
|
* @throws Exception Key does not exist
|
||||||
* @return mixed Value of key
|
* @return mixed Value of key
|
||||||
*/
|
*/
|
||||||
public function get($key)
|
public function get($key)
|
||||||
@ -68,9 +66,8 @@ class Collection
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes key
|
* Removes key
|
||||||
*
|
*
|
||||||
* @param mixed $key Key to remove
|
* @param mixed $key Key to remove
|
||||||
*
|
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function remove($key)
|
public function remove($key)
|
||||||
|
@ -10,9 +10,8 @@ class Options extends Collection
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies options to Request object
|
* Applies options to Request object
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function applyTo(Request $request)
|
public function applyTo(Request $request)
|
||||||
@ -26,7 +25,7 @@ class Options extends Collection
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares array for intelligent setters
|
* Prepares array for intelligent setters
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function loadCurlConstantsTable()
|
public static function loadCurlConstantsTable()
|
||||||
@ -44,10 +43,10 @@ class Options extends Collection
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Intelligent setters
|
* Intelligent setters
|
||||||
*
|
*
|
||||||
* @param string $name Function name
|
* @param string $name Function name
|
||||||
* @param array $args Arguments
|
* @param array $args Arguments
|
||||||
*
|
* @throws Exception Invalid CURLOPT_ constant has been specified
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function __call($name, $args)
|
public function __call($name, $args)
|
||||||
|
@ -24,8 +24,6 @@ class Request extends EventDispatcher implements RequestInterface
|
|||||||
* Create new cURL handle
|
* Create new cURL handle
|
||||||
*
|
*
|
||||||
* @param string $url The URL to fetch.
|
* @param string $url The URL to fetch.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __construct($url = null)
|
public function __construct($url = null)
|
||||||
{
|
{
|
||||||
@ -39,8 +37,6 @@ class Request extends EventDispatcher implements RequestInterface
|
|||||||
* Closes cURL resource and frees the memory.
|
* Closes cURL resource and frees the memory.
|
||||||
* It is neccessary when you make a lot of requests
|
* It is neccessary when you make a lot of requests
|
||||||
* and you want to avoid fill up the memory.
|
* and you want to avoid fill up the memory.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
@ -67,7 +63,6 @@ class Request extends EventDispatcher implements RequestInterface
|
|||||||
* Sets Options
|
* Sets Options
|
||||||
*
|
*
|
||||||
* @param Options $options Options
|
* @param Options $options Options
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setOptions(Options $options)
|
public function setOptions(Options $options)
|
||||||
|
@ -22,7 +22,7 @@ class RequestsQueue extends EventDispatcher implements RequestsQueueInterface, C
|
|||||||
protected $runningCount = 0;
|
protected $runningCount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array Array of requests attached
|
* @var Request[] Array of requests attached
|
||||||
*/
|
*/
|
||||||
protected $queue = array();
|
protected $queue = array();
|
||||||
|
|
||||||
@ -32,9 +32,7 @@ class RequestsQueue extends EventDispatcher implements RequestsQueueInterface, C
|
|||||||
protected $running = array();
|
protected $running = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Initializes curl_multi handler
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@ -70,7 +68,6 @@ class RequestsQueue extends EventDispatcher implements RequestsQueueInterface, C
|
|||||||
* Overrides default options with given Options object
|
* Overrides default options with given Options object
|
||||||
*
|
*
|
||||||
* @param Options $defaultOptions New options
|
* @param Options $defaultOptions New options
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setDefaultOptions(Options $defaultOptions)
|
public function setDefaultOptions(Options $defaultOptions)
|
||||||
@ -92,7 +89,6 @@ class RequestsQueue extends EventDispatcher implements RequestsQueueInterface, C
|
|||||||
* Attach request to queue.
|
* Attach request to queue.
|
||||||
*
|
*
|
||||||
* @param Request $request Request to add
|
* @param Request $request Request to add
|
||||||
*
|
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function attach(Request $request)
|
public function attach(Request $request)
|
||||||
@ -105,7 +101,6 @@ class RequestsQueue extends EventDispatcher implements RequestsQueueInterface, C
|
|||||||
* Detach request from queue.
|
* Detach request from queue.
|
||||||
*
|
*
|
||||||
* @param Request $request Request to remove
|
* @param Request $request Request to remove
|
||||||
*
|
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function detach(Request $request)
|
public function detach(Request $request)
|
||||||
@ -169,7 +164,7 @@ class RequestsQueue extends EventDispatcher implements RequestsQueueInterface, C
|
|||||||
/**
|
/**
|
||||||
* Returns requests present in $queue but not in $running
|
* Returns requests present in $queue but not in $running
|
||||||
*
|
*
|
||||||
* @return array Array of requests
|
* @return Request[] Array of requests
|
||||||
*/
|
*/
|
||||||
protected function getRequestsNotRunning()
|
protected function getRequestsNotRunning()
|
||||||
{
|
{
|
||||||
@ -178,7 +173,8 @@ class RequestsQueue extends EventDispatcher implements RequestsQueueInterface, C
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Download available data on socket.
|
* Download available data on socket.
|
||||||
*
|
*
|
||||||
|
* @throws Exception
|
||||||
* @return bool TRUE when there are any requests on queue, FALSE when finished
|
* @return bool TRUE when there are any requests on queue, FALSE when finished
|
||||||
*/
|
*/
|
||||||
public function socketPerform()
|
public function socketPerform()
|
||||||
@ -186,8 +182,7 @@ class RequestsQueue extends EventDispatcher implements RequestsQueueInterface, C
|
|||||||
if ($this->count() == 0) {
|
if ($this->count() == 0) {
|
||||||
throw new Exception('Cannot perform if there are no requests in queue.');
|
throw new Exception('Cannot perform if there are no requests in queue.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$notRunning = $this->getRequestsNotRunning();
|
$notRunning = $this->getRequestsNotRunning();
|
||||||
do {
|
do {
|
||||||
/**
|
/**
|
||||||
@ -221,8 +216,8 @@ class RequestsQueue extends EventDispatcher implements RequestsQueueInterface, C
|
|||||||
* return FALSE on a select failure or timeout (from the underlying
|
* return FALSE on a select failure or timeout (from the underlying
|
||||||
* select system call)
|
* select system call)
|
||||||
*
|
*
|
||||||
* @param float $timeout Maximum time to wait
|
* @param float|int $timeout Maximum time to wait
|
||||||
*
|
* @throws Exception
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function socketSelect($timeout = 1)
|
public function socketSelect($timeout = 1)
|
||||||
|
@ -12,8 +12,6 @@ class Response
|
|||||||
*
|
*
|
||||||
* @param Request $request Request
|
* @param Request $request Request
|
||||||
* @param string $content Content of reponse
|
* @param string $content Content of reponse
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Request $request, $content = null)
|
public function __construct(Request $request, $content = null)
|
||||||
{
|
{
|
||||||
@ -31,7 +29,6 @@ class Response
|
|||||||
* the following elements (which correspond to opt), or FALSE on failure.
|
* the following elements (which correspond to opt), or FALSE on failure.
|
||||||
*
|
*
|
||||||
* @param int $key One of the CURLINFO_* constants
|
* @param int $key One of the CURLINFO_* constants
|
||||||
*
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getInfo($key = null)
|
public function getInfo($key = null)
|
||||||
@ -53,7 +50,6 @@ class Response
|
|||||||
* Sets error instance
|
* Sets error instance
|
||||||
*
|
*
|
||||||
* @param Error $error Error to set
|
* @param Error $error Error to set
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setError(Error $error)
|
public function setError(Error $error)
|
||||||
|
Loading…
Reference in New Issue
Block a user