CkIPException
What CkIP throws — only when asked.
Raised by any CkIP method called with throwIfInvalid: true
when a value could not be used. Never thrown otherwise: by default every CkIP method
returns empty, false or the fallback instead. 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:
CkIP.Address: cannot use "127.1" (String) as an IP address — not four dot-separated numbers.
Properties
Every property is public readonly.
| Property | Type | What it holds |
|---|---|---|
Expected |
string |
What the value was meant to be — 'an IP address'. |
Input |
mixed |
From CkException: the value that failed, untouched. |
Reason |
string |
From CkException: why, in a few words. |
Quick look
use SafeCoder\CommonKit\CkIP;
use SafeCoder\CommonKit\Exceptions\CkIPException;
try {
CkIP::Address(
input: '127.1',
throwIfInvalid: true
);
} catch (CkIPException $error) {
echo $error->Reason; // -> 'not four dot-separated numbers'
echo $error->Expected; // -> 'an IP address'
}