Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Eco\Contracts; |
| 6 | |
| 7 | /** |
| 8 | * Contract for error codes carried by {@see \Eco\Error}. |
| 9 | * |
| 10 | * Implement this interface on your own enum to define domain-specific |
| 11 | * error codes beyond the built-in ones provided by {@see \Eco\ErrorCode}. |
| 12 | * |
| 13 | * ```php |
| 14 | * enum AppErrorCode: string implements ErrorCodeContract |
| 15 | * { |
| 16 | * case UNAUTHORIZED = 'UNAUTHORIZED'; |
| 17 | * case INSUFFICIENT_BALANCE = 'INSUFFICIENT_BALANCE'; |
| 18 | * case ORDER_ALREADY_CANCELLED = 'ORDER_ALREADY_CANCELLED'; |
| 19 | * |
| 20 | * public function value(): string |
| 21 | * { |
| 22 | * return $this->value; |
| 23 | * } |
| 24 | * } |
| 25 | * ``` |
| 26 | */ |
| 27 | interface ErrorCodeContract |
| 28 | { |
| 29 | /** |
| 30 | * Returns the machine-readable string identifier for this error code. |
| 31 | * Used for serialization, API responses, and programmatic comparisons. |
| 32 | */ |
| 33 | public function value(): string; |
| 34 | } |