AbstractResponseTranslator
abstract class AbstractResponseTranslator (View source)
Shared base for all registrar ResponseTranslator implementations.
The translate()/findMatch() pipeline is identical across brands: empty->"empty", "httperror|" splitting, static-template lookup with {HTTPERROR} injection, invalid-template fallback, the two description-map rewrite loops, findMatch(), and placeholder replacement. Only a few narrow points differ, supplied by the abstract hooks below:
- the static template container (templates())
- the two description rewrite maps (descriptionRegexMap()/descriptionRawPatternMap())
- the response field carrying the human-readable text (fieldName(): "description" for CNR, "message" for IBS)
- the "missing/empty required field" check that triggers the invalid fallback (hasMissingRequiredFields(): CODE/DESCRIPTION for CNR, status for IBS)
Placeholder stripping is deliberately unified on the per-field, per-token callback (formerly CNR-only): unknown {UPPER} tokens are removed only inside the human-readable field, leaving {UPPER} content in other data fields untouched. The former IBS behaviour stripped such tokens globally across the whole response, which risked corrupting legitimate data fields — replacePlaceholders() below is the single correct behaviour for both brands.
Methods
The brand's static template container (id => raw template string).
plain-string description keys for translation; keys are preg_quote'd before matching
raw regex pattern keys for translation; keys are used as-is (not preg_quote'd)
Name of the response field carrying the human-readable text ("description" for CNR, "message" for IBS).
Whether the raw response is missing or has an empty required field (CNR: CODE/DESCRIPTION, IBS: status) and should therefore fall back to the "invalid" template.
translate a raw api response
Replace known placeholders in the human-readable field while preserving literal brace content and unknown-token content in other fields.
Details
abstract static protected array
templates()
The brand's static template container (id => raw template string).
abstract static protected array
descriptionRegexMap()
plain-string description keys for translation; keys are preg_quote'd before matching
abstract static protected array
descriptionRawPatternMap()
raw regex pattern keys for translation; keys are used as-is (not preg_quote'd)
abstract static protected string
fieldName()
Name of the response field carrying the human-readable text ("description" for CNR, "message" for IBS).
abstract static protected bool
hasMissingRequiredFields(string $raw)
Whether the raw response is missing or has an empty required field (CNR: CODE/DESCRIPTION, IBS: status) and should therefore fall back to the "invalid" template.
static string
translate(string $raw, array $cmd, array $placeholders = [])
translate a raw api response
static protected string
replacePlaceholders(string $raw, array $placeholders)
Replace known placeholders in the human-readable field while preserving literal brace content and unknown-token content in other fields.
Operates line-by-line on the brand's field (see fieldName()): provided placeholders are substituted, unknown {UPPER} tokens are stripped, and any other brace content (e.g. lowercase %{i} in SPF records) is left untouched.