final class ResponseTemplateManager extends AbstractResponseTemplateManager (View source)

CNR ResponseTemplateManager

Constants

private BUILTIN_TEMPLATES

CNR's built-in templates. A constant, not a property: each registry instance copies these at construction and mutates only its copy, so there is no route by which one caller's override reaches another (RSRMID-2941).

Methods

static array
builtinTemplates()

No description

createResponseFromTemplateId(string $templateId)

Create a CNR Response instance from a template id.

newResponseParser()

Instantiate the CNR response parser.

static array
matchKeys()

CNR compares templates on the CODE and DESCRIPTION hash keys.

addTemplate(string $templateId, string $plain, string|null $description = null)

Register a template on this registry.

array
getTemplates()

Every template in this registry as a Response, keyed by template id.

array
getRawTemplates()

Every template in this registry as its raw wire text.

bool
hasTemplate(string $templateId)

Check if given template exists in this registry.

bool
isTemplateMatchHash(array $responseHash, string $templateId)

Check if given API response hash matches a given template by code and description

bool
isTemplateMatchPlain(string $plain, string $templateId)

Check if given API plain response matches a given template by code and description

string
generateTemplate(string $code, string $description)

Generate API response template string for given code and description

getTemplate(string $templateId)

Get response template instance from this registry

Details

__construct()

No description

static protected array builtinTemplates()

No description

Return Value

array

protected ResponseInterface createResponseFromTemplateId(string $templateId)

Create a CNR Response instance from a template id.

The registry is handed to the Response so the template id resolves against this object — that hand-off is what replaced the global lookup.

Parameters

string $templateId

Return Value

ResponseInterface

protected ResponseParserInterface newResponseParser()

Instantiate the CNR response parser.

static protected array matchKeys()

CNR compares templates on the CODE and DESCRIPTION hash keys.

Return Value

array

ResponseTemplateManagerInterface addTemplate(string $templateId, string $plain, string|null $description = null)

Register a template on this registry.

Parameters

string $templateId
string $plain

API plain response, or API response code when $description is given

string|null $description

Return Value

ResponseTemplateManagerInterface

array getTemplates()

Every template in this registry as a Response, keyed by template id.

Return Value

array

array getRawTemplates()

Every template in this registry as its raw wire text.

Return Value

array

bool hasTemplate(string $templateId)

Check if given template exists in this registry.

Parameters

string $templateId

Return Value

bool

bool isTemplateMatchHash(array $responseHash, string $templateId)

Check if given API response hash matches a given template by code and description

Parameters

array $responseHash
string $templateId

Return Value

bool

bool isTemplateMatchPlain(string $plain, string $templateId)

Check if given API plain response matches a given template by code and description

Parameters

string $plain

API plain response

string $templateId

Return Value

bool

string generateTemplate(string $code, string $description)

Generate API response template string for given code and description

Parameters

string $code
string $description

Return Value

string

ResponseInterface getTemplate(string $templateId)

Get response template instance from this registry

Parameters

string $templateId

Return Value

ResponseInterface