ResponseTemplateManager
final class ResponseTemplateManager extends AbstractResponseTemplateManager (View source)
IBS ResponseTemplateManager
Properties
| static string[] | $templates | template container |
Methods
Generate API response template string for given status and description
Get response template instance from template container
Create an IBS Response instance from a template id or raw response.
Instantiate the IBS response parser.
IBS compares templates on the status and message hash keys.
Add response template to template container
Restore the brand's built-in templates, discarding everything {addTemplate()} has registered since.
Return all available response templates
Check if given template exists in template container
Check if given API response hash matches a given template by code and description
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 status and description
static ResponseInterface
getTemplate(string $templateId)
Get response template instance from template container
static protected ResponseInterface
createResponse(string $raw)
Create an IBS Response instance from a template id or raw response.
static protected ResponseParserInterface
newResponseParser()
Instantiate the IBS response parser.
static protected array
matchKeys()
IBS compares templates on the status and message hash keys.
static AbstractResponseTemplateManager
addTemplate(string $templateId, string $plain, string|null $description = null)
Add response template to template container
static void
resetTemplates()
Restore the brand's built-in templates, discarding everything {addTemplate()} has registered since.
The container is public static state with process lifetime, so a template registered for one scenario stays visible to every later one — across test classes in the same PHPUnit process, and in any long-lived consumer that registers templates per request. Call this when a scenario ends (e.g. from tearDownAfterClass()) so the next one starts from the brand defaults.
Scope, stated rather than implied: this is the counterpart of {\CNIC\addTemplate()}, not a general undo. It restores what the container held the first time addTemplate() ran for this class, so it is per brand and a no-op when the class was never added to. A direct assignment to the public $templates property is outside its reach — closing that second writer would mean making the property non-public, which {\CNIC\CNR\ResponseTranslator::templates()} reads across a class boundary, so it is a separate change. Go through addTemplate().
static array
getTemplates()
Return all available response templates
static bool
hasTemplate(string $templateId)
Check if given template exists in template container
static bool
isTemplateMatchHash(array $responseHash, string $templateId)
Check if given API response hash matches a given template by code and description
static bool
isTemplateMatchPlain(string $plain, string $templateId)
Check if given API plain response matches a given template by code and description