Skip to content

Commit

Permalink
Cleanup: Renames handleRequestCallback to requestCallback.
Browse files Browse the repository at this point in the history
  • Loading branch information
adri committed Jan 31, 2014
1 parent 6c557a5 commit 29eb0bf
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
14 changes: 7 additions & 7 deletions src/VCR/LibraryHooks/Curl.php
Expand Up @@ -18,7 +18,7 @@ class Curl implements LibraryHook
/**
* @var \Closure Callback which will be executed when a request is intercepted.
*/
protected static $handleRequestCallback;
protected static $requestCallback;

/**
* @var string Current status of this hook, either enabled or disabled.
Expand Down Expand Up @@ -70,9 +70,9 @@ public function __construct(AbstractFilter $filter, StreamProcessor $processor)
/**
* @inheritDoc
*/
public function enable(\Closure $handleRequestCallback)
public function enable(\Closure $requestCallback)
{
Assertion::isCallable($handleRequestCallback, 'No valid callback for handling requests defined.');
Assertion::isCallable($requestCallback, 'No valid callback for handling requests defined.');

if (static::$status == self::ENABLED) {
return;
Expand All @@ -82,7 +82,7 @@ public function enable(\Closure $handleRequestCallback)
$this->processor->appendFilter($this->filter);
$this->processor->intercept();

self::$handleRequestCallback = $handleRequestCallback;
self::$requestCallback = $requestCallback;

static::$status = self::ENABLED;
}
Expand All @@ -96,7 +96,7 @@ public function disable()
return;
}

self::$handleRequestCallback = null;
self::$requestCallback = null;

static::$status = self::DISABLED;
}
Expand Down Expand Up @@ -143,8 +143,8 @@ public static function init($url = null)

public static function exec($ch)
{
$handleRequestCallback = self::$handleRequestCallback;
self::$responses[(int) $ch] = $handleRequestCallback(self::$requests[(int) $ch]);
$requestCallback = self::$requestCallback;
self::$responses[(int) $ch] = $requestCallback(self::$requests[(int) $ch]);

return CurlHelper::handleOutput(
self::$responses[(int) $ch],
Expand Down
2 changes: 1 addition & 1 deletion src/VCR/LibraryHooks/LibraryHook.php
Expand Up @@ -25,7 +25,7 @@ interface LibraryHook
* @throws VCR\VCRException When specified callback is not callable.
* @return void
*/
public function enable(\Closure $handleRequestCallback);
public function enable(\Closure $requestCallback);

/**
* Disables library hook, so no http interactions of
Expand Down
16 changes: 8 additions & 8 deletions src/VCR/LibraryHooks/Soap.php
Expand Up @@ -16,7 +16,7 @@ class Soap implements LibraryHook
/**
* @var string
*/
private static $handleRequestCallback;
private static $requestCallback;
/**
* @var string
*/
Expand Down Expand Up @@ -57,19 +57,19 @@ public function doRequest($request, $location, $action, $version, $one_way = 0)
$vcrRequest->addHeader('Content-Type', $contentType . '; charset=utf-8; action="' . $action . '"');
$vcrRequest->setBody($request);

$handleRequestCallback = self::$handleRequestCallback;
$response = $handleRequestCallback($vcrRequest);
$requestCallback = self::$requestCallback;
$response = $requestCallback($vcrRequest);

return (string) $response->getBody(true);
}

/**
* @inheritDoc
*/
public function enable(\Closure $handleRequestCallback)
public function enable(\Closure $requestCallback)
{
Assertion::isCallable($handleRequestCallback, 'No valid callback for handling requests defined.');
self::$handleRequestCallback = $handleRequestCallback;
Assertion::isCallable($requestCallback, 'No valid callback for handling requests defined.');
self::$requestCallback = $requestCallback;

if ($this->status == self::ENABLED) {
return;
Expand All @@ -92,7 +92,7 @@ public function disable()
return;
}

self::$handleRequestCallback = null;
self::$requestCallback = null;

$this->status = self::DISABLED;
}
Expand All @@ -107,7 +107,7 @@ public function isEnabled()

public function __destruct()
{
self::$handleRequestCallback = null;
self::$requestCallback = null;
}

}
16 changes: 8 additions & 8 deletions src/VCR/LibraryHooks/StreamWrapper.php
Expand Up @@ -11,7 +11,7 @@
*/
class StreamWrapper implements LibraryHook
{
private static $handleRequestCallback;
private static $requestCallback;

private $position;

Expand All @@ -24,10 +24,10 @@ public function __construct()
{
}

public function enable(\Closure $handleRequestCallback)
public function enable(\Closure $requestCallback)
{
Assertion::isCallable($handleRequestCallback, 'No valid callback for handling requests defined.');
self::$handleRequestCallback = $handleRequestCallback;
Assertion::isCallable($requestCallback, 'No valid callback for handling requests defined.');
self::$requestCallback = $requestCallback;
stream_wrapper_unregister('http');
stream_wrapper_register('http', __CLASS__, STREAM_IS_URL);

Expand All @@ -37,7 +37,7 @@ public function enable(\Closure $handleRequestCallback)

public function disable()
{
self::$handleRequestCallback = null;
self::$requestCallback = null;
stream_wrapper_restore('http');
stream_wrapper_restore('https');
}
Expand All @@ -52,8 +52,8 @@ public function isEnabled()

public function stream_open($path, $mode, $options, &$opened_path)
{
$handleRequestCallback = self::$handleRequestCallback;
$this->response = $handleRequestCallback(new Request('GET', $path));
$requestCallback = self::$requestCallback;
$this->response = $requestCallback(new Request('GET', $path));

return (string) $this->response->getBody();
}
Expand Down Expand Up @@ -127,6 +127,6 @@ public function stream_metadata($path, $option, $var)

public function __destruct()
{
self::$handleRequestCallback = null;
self::$requestCallback = null;
}
}
2 changes: 1 addition & 1 deletion tests/VCR/LibraryHooks/CurlTest.php
Expand Up @@ -194,7 +194,7 @@ public function curlMethodsProvider()
/**
* @return \callable
*/
protected function getTestCallback($handleRequestCallback = null)
protected function getTestCallback($requestCallback = null)
{
$testClass = $this;
return function ($request) use ($testClass) {
Expand Down
4 changes: 2 additions & 2 deletions tests/VCR/LibraryHooks/SoapTest.php
Expand Up @@ -79,7 +79,7 @@ public function testShouldHandleSOAPVersion12()
}

/**
* @param null $handleRequestCallback
* @param null $requestCallback
*
* @return \callable
*/
Expand All @@ -92,7 +92,7 @@ protected function getContentCheckCallback()
}

/**
* @param null $handleRequestCallback
* @param null $requestCallback
*
* @return \callable
*/
Expand Down

0 comments on commit 29eb0bf

Please sign in to comment.