final class ResponseTemplateManager (View source)

CNR ResponseTemplateManager

Properties

static string[] $templates

Template container

Methods

static string
generateTemplate(string $code, string $description)

Generate API response template string for given code and description

addTemplate(string $id, string $plain, string|null $descr = null)

Add response template to template container

static Response
getTemplate(string $id)

Get response template instance from template container

static array
getTemplates()

Return all available response templates

static bool
hasTemplate(string $id)

Check if given template exists in template container

static bool
isTemplateMatchHash(array $tpl, string $id)

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

static bool
isTemplateMatchPlain(string $plain, string $id)

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

Details

static string generateTemplate(string $code, string $description)

Generate API response template string for given code and description

Parameters

string $code

API response code

string $description

API response description

Return Value

string

static ResponseTemplateManager addTemplate(string $id, string $plain, string|null $descr = null)

Add response template to template container

Parameters

string $id

template id

string $plain

API plain response or API response code (when providing $descr)

string|null $descr

API response description (optional)

Return Value

ResponseTemplateManager

static Response getTemplate(string $id)

Get response template instance from template container

Parameters

string $id

template id

Return Value

Response

static array getTemplates()

Return all available response templates

Return Value

array

static bool hasTemplate(string $id)

Check if given template exists in template container

Parameters

string $id

template id

Return Value

bool

static bool isTemplateMatchHash(array $tpl, string $id)

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

Parameters

array $tpl

api response hash

string $id

template id

Return Value

bool

static bool isTemplateMatchPlain(string $plain, string $id)

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

Parameters

string $plain

API plain response

string $id

template id

Return Value

bool