PHP Класс VCR\Videorecorder

If turned on, a videorecorder will intercept HTTP requests using hooks into libraries like cUrl, SOAP and streamWrappers. Requests and responses will be recorded on a inserted cassette. If a request is already recorded on a cassette the videorecorder will play back its response and not issue a HTTP request. If turned off, HTTP requests won't be intercepted and will hit their original servers.
Автор: Adrian Philipp ([email protected])
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$cassette Cassette on which to store requests and responses.
$client Client to use to issue HTTP requests.
$config Config options like which library hooks to use.
$eventDispatcher Symfony\Component\EventDispatcher\EventDispatcherInterface
$factory Factory which can create instances and resolve dependencies.
$isOn Flag if this videorecorder is turned on or not.

Открытые методы

Метод Описание
__construct ( Configuration $config, VCR\Util\HttpClient $client, vcr\VCRFactory $factory ) Creates a videorecorder instance.
__destruct ( ) Turns off this videorecorder when instance is destroyed.
configure ( ) : Configuration Returns the current Configuration for this videorecorder.
eject ( ) : void Eject the currently inserted cassette.
getEventDispatcher ( ) : Symfony\Component\EventDispatcher\EventDispatcherInterface
handleRequest ( Request $request ) : Response Records, sends or plays back a intercepted request.
insertCassette ( string $cassetteName ) : void Inserts a cassette to record responses and requests on.
setEventDispatcher ( Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher )
turnOff ( ) : void Turns off this videorecorder.
turnOn ( ) : void Turns on this videorecorder.

Защищенные методы

Метод Описание
disableLibraryHooks ( ) : void Disables all library hooks.
enableLibraryHooks ( ) : void Enables configured library hooks.

Приватные методы

Метод Описание
dispatch ( string $eventName, Symfony\Component\EventDispatcher\Event $event = null ) : Symfony\Component\EventDispatcher\Event Dispatches an event to all registered listeners.

Описание методов

__construct() публичный Метод

Creates a videorecorder instance.
public __construct ( Configuration $config, VCR\Util\HttpClient $client, vcr\VCRFactory $factory )
$config Configuration Config options like which library hooks to use.
$client VCR\Util\HttpClient Client which is used to issue HTTP requests.
$factory vcr\VCRFactory Factory which can create instances and resolve dependencies.

__destruct() публичный Метод

Turns off this videorecorder when instance is destroyed.
public __destruct ( )

configure() публичный Метод

Returns the current Configuration for this videorecorder.
public configure ( ) : Configuration
Результат Configuration Configuration for this videorecorder.

disableLibraryHooks() защищенный Метод

Disables all library hooks.
protected disableLibraryHooks ( ) : void
Результат void

eject() публичный Метод

Recording and playing back requests won't be possible after ejecting.
public eject ( ) : void
Результат void

enableLibraryHooks() защищенный Метод

Enables configured library hooks.
protected enableLibraryHooks ( ) : void
Результат void

getEventDispatcher() публичный Метод

public getEventDispatcher ( ) : Symfony\Component\EventDispatcher\EventDispatcherInterface
Результат Symfony\Component\EventDispatcher\EventDispatcherInterface

handleRequest() публичный Метод

If a request was already recorded on a cassette it's response is returned, otherwise the request is issued and it's response recorded (and returned).
public handleRequest ( Request $request ) : Response
$request Request Intercepted request.
Результат Response Response for the intercepted request.

insertCassette() публичный Метод

Inserts a cassette to record responses and requests on.
public insertCassette ( string $cassetteName ) : void
$cassetteName string Name of the cassette (used for the cassette filename).
Результат void

setEventDispatcher() публичный Метод

public setEventDispatcher ( Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher )
$dispatcher Symfony\Component\EventDispatcher\EventDispatcherInterface

turnOff() публичный Метод

Library hooks will be disabled and cassettes ejected.
public turnOff ( ) : void
Результат void

turnOn() публичный Метод

This enables configured library hooks.
public turnOn ( ) : void
Результат void

Описание свойств

$cassette защищенное свойство

Cassette on which to store requests and responses.
protected $cassette

$client защищенное свойство

Client to use to issue HTTP requests.
protected $client

$config защищенное свойство

Config options like which library hooks to use.
protected $config

$eventDispatcher защищенное свойство

protected EventDispatcherInterface,Symfony\Component\EventDispatcher $eventDispatcher
Результат Symfony\Component\EventDispatcher\EventDispatcherInterface

$factory защищенное свойство

Factory which can create instances and resolve dependencies.
protected $factory

$isOn защищенное свойство

Flag if this videorecorder is turned on or not.
protected $isOn