PHP Class VCR\Cassette

Datei anzeigen Open project: php-vcr/php-vcr Class Usage Examples

Protected Properties

Property Type Description
$config Configuration VCR configuration.
$name string Casette name
$storage VCR\Storage\Storage Storage used to store records and request pairs.

Public Methods

Method Description
__construct ( string $name, Configuration $config, VCR\Storage\Storage $storage ) Creates a new cassette.
getName ( ) : string Returns the name of the current cassette.
hasResponse ( Request $request ) : boolean Returns true if a response was recorded for specified request.
isNew ( ) : boolean Returns true if the cassette was created recently.
playback ( Request $request ) : Response | null Returns a response for given request or null if not found.
record ( Request $request, Response $response ) : void Records a request and response pair.

Protected Methods

Method Description
getRequestMatchers ( ) : array Returns a list of callbacks to configured request matchers.

Method Details

__construct() public method

Creates a new cassette.
public __construct ( string $name, Configuration $config, VCR\Storage\Storage $storage )
$name string Name of the cassette.
$config Configuration Configuration to use for this cassette.
$storage VCR\Storage\Storage Storage to use for requests and responses.

getName() public method

Returns the name of the current cassette.
public getName ( ) : string
return string Current cassette name.

getRequestMatchers() protected method

Returns a list of callbacks to configured request matchers.
protected getRequestMatchers ( ) : array
return array List of callbacks to configured request matchers.

hasResponse() public method

Returns true if a response was recorded for specified request.
public hasResponse ( Request $request ) : boolean
$request Request Request to check if it was recorded.
return boolean True if a response was recorded for specified request.

isNew() public method

Returns true if the cassette was created recently.
public isNew ( ) : boolean
return boolean

playback() public method

Returns a response for given request or null if not found.
public playback ( Request $request ) : Response | null
$request Request Request.
return Response | null Response for specified request.

record() public method

Records a request and response pair.
public record ( Request $request, Response $response ) : void
$request Request Request to record.
$response Response Response to record.
return void

Property Details

$config protected_oe property

VCR configuration.
protected Configuration,vcr $config
return Configuration

$name protected_oe property

Casette name
protected string $name
return string

$storage protected_oe property

Storage used to store records and request pairs.
protected Storage,VCR\Storage $storage
return VCR\Storage\Storage