CkIntlException
What CkIntl throws — only when asked.
Raised by any CkIntl method called with
throwIfInvalid: true when neither the value nor the fallback can be used. Never
thrown otherwise: by default those methods answer '' instead — and the …Mask
methods, made for display, answer a masked shape and never throw at all. Final,
and derived from CkException.
The message names the method, shows the value with its type, says what it was meant to be and why it failed:
CkIntl.Phone: cannot use "junk" (String) as a phone number in international form — no international prefix: it must start with +, 00 or 011.
Properties
Every property is public readonly.
| Property | Type | What it holds |
|---|---|---|
Expected |
string |
What the value was meant to be — 'a phone number in international form', 'an IBAN' or 'a BIC', depending on the method. |
Input |
mixed |
From CkException: the value that failed, untouched. |
Reason |
string |
From CkException: why, in a few words. |
Quick look
use SafeCoder\CommonKit\CkIntl;
use SafeCoder\CommonKit\Exceptions\CkIntlException;
try {
CkIntl::Phone(
input: 'junk',
throwIfInvalid: true
);
} catch (CkIntlException $error) {
echo $error->Reason; // -> 'no international prefix: it must start with +, 00 or 011'
echo $error->Expected; // -> 'a phone number in international form'
}