PHP Class VCR\LibraryHooks\CurlHook

Inheritance: implements VCR\LibraryHooks\LibraryHook
Show file Open project: php-vcr/php-vcr

Protected Properties

Property Type Description
$curlOptions Additinal curl options, which are not stored within a request.
$multiExecLastCh Last active curl_multi_exec() handle.
$multiHandles All curl handles which belong to curl_multi handles.
$requestCallback Callback which will be executed when a request is intercepted.
$requests All requests which have been intercepted.
$responses All responses which have been intercepted.
$status Current status of this hook, either enabled or disabled.

Public Methods

Method Description
__callStatic ( string $method, array $args ) : mixed Calls the intercepted curl method if library hook is disabled, otherwise the real one.
__construct ( VCR\CodeTransform\AbstractCodeTransform $codeTransformer, StreamProcessor $processor ) Creates a new cURL hook instance.
curlExec ( resource $curlHandle ) : mixed Perform a cURL session.
curlGetinfo ( resource $curlHandle, integer $option ) : mixed Get information regarding a specific transfer.
curlInit ( string $url = null ) : resource Initialize a cURL session.
curlMultiAddHandle ( resource $multiHandle, resource $curlHandle ) Add a normal cURL handle to a cURL multi handle.
curlMultiExec ( resource $multiHandle, integer &$stillRunning ) : integer Run the sub-connections of the current cURL handle.
curlMultiInfoRead ( ) : array | boolean Get information about the current transfers.
curlMultiRemoveHandle ( resource $multiHandle, resource $curlHandle ) Remove a multi handle from a set of cURL handles.
curlReset ( resource $curlHandle ) Reset a cURL session.
curlSetopt ( resource $curlHandle, integer $option, mixed $value ) : boolean Set an option for a cURL transfer.
curlSetoptArray ( resource $curlHandle, array $options ) Set multiple options for a cURL transfer.
disable ( )
enable ( Closure $requestCallback )
isEnabled ( )

Method Details

__callStatic() public static method

Calls the intercepted curl method if library hook is disabled, otherwise the real one.
public static __callStatic ( string $method, array $args ) : mixed
$method string cURL method to call, example: curl_info()
$args array cURL arguments for this function.
return mixed cURL function return type.

__construct() public method

Creates a new cURL hook instance.
public __construct ( VCR\CodeTransform\AbstractCodeTransform $codeTransformer, StreamProcessor $processor )
$codeTransformer VCR\CodeTransform\AbstractCodeTransform
$processor VCR\Util\StreamProcessor

curlExec() public static method

Perform a cURL session.
public static curlExec ( resource $curlHandle ) : mixed
$curlHandle resource A cURL handle returned by curl_init().
return mixed Returns TRUE on success or FALSE on failure. However, if the CURLOPT_RETURNTRANSFER option is set, it will return the result on success, FALSE on failure.

curlGetinfo() public static method

Get information regarding a specific transfer.
public static curlGetinfo ( resource $curlHandle, integer $option ) : mixed
$curlHandle resource A cURL handle returned by curl_init().
$option integer A cURL option defined in the cURL Predefined Constants.
return mixed

curlInit() public static method

Initialize a cURL session.
public static curlInit ( string $url = null ) : resource
$url string (Optional) url.
return resource cURL handle.

curlMultiAddHandle() public static method

Add a normal cURL handle to a cURL multi handle.
public static curlMultiAddHandle ( resource $multiHandle, resource $curlHandle )
$multiHandle resource A cURL multi handle returned by curl_multi_init().
$curlHandle resource A cURL handle returned by curl_init().

curlMultiExec() public static method

Run the sub-connections of the current cURL handle.
public static curlMultiExec ( resource $multiHandle, integer &$stillRunning ) : integer
$multiHandle resource A cURL multi handle returned by curl_multi_init().
$stillRunning integer A reference to a flag to tell whether the operations are still running.
return integer A cURL code defined in the cURL Predefined Constants.

curlMultiInfoRead() public static method

Get information about the current transfers.
public static curlMultiInfoRead ( ) : array | boolean
return array | boolean On success, returns an associative array for the message, FALSE on failure.

curlMultiRemoveHandle() public static method

Remove a multi handle from a set of cURL handles.
public static curlMultiRemoveHandle ( resource $multiHandle, resource $curlHandle )
$multiHandle resource A cURL multi handle returned by curl_multi_init().
$curlHandle resource A cURL handle returned by curl_init().

curlReset() public static method

Reset a cURL session.
public static curlReset ( resource $curlHandle )
$curlHandle resource A cURL handle returned by curl_init().

curlSetopt() public static method

Set an option for a cURL transfer.
public static curlSetopt ( resource $curlHandle, integer $option, mixed $value ) : boolean
$curlHandle resource A cURL handle returned by curl_init().
$option integer The CURLOPT_XXX option to set.
$value mixed The value to be set on option.
return boolean Returns TRUE on success or FALSE on failure.

curlSetoptArray() public static method

Set multiple options for a cURL transfer.
public static curlSetoptArray ( resource $curlHandle, array $options )
$curlHandle resource A cURL handle returned by curl_init().
$options array An array specifying which options to set and their values.

disable() public method

public disable ( )

enable() public method

public enable ( Closure $requestCallback )
$requestCallback Closure

isEnabled() public method

public isEnabled ( )

Property Details

$curlOptions protected static property

Additinal curl options, which are not stored within a request.
protected static $curlOptions

$multiExecLastCh protected static property

Last active curl_multi_exec() handle.
protected static $multiExecLastCh

$multiHandles protected static property

All curl handles which belong to curl_multi handles.
protected static $multiHandles

$requestCallback protected static property

Callback which will be executed when a request is intercepted.
protected static $requestCallback

$requests protected static property

All requests which have been intercepted.
protected static $requests

$responses protected static property

All responses which have been intercepted.
protected static $responses

$status protected static property

Current status of this hook, either enabled or disabled.
protected static $status