| 1 | <?php |
||
| 9 | class Error |
||
| 10 | { |
||
| 11 | const ERROR_CODE = 'UNKNOWN'; |
||
| 12 | |||
| 13 | /** @var string[] */ |
||
| 14 | protected $params = [ |
||
| 15 | 'code' => self::ERROR_CODE |
||
| 16 | ]; |
||
| 17 | |||
| 18 | /** @var string */ |
||
| 19 | protected $message = 'ERROR(%code%) occurred'; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Error constructor |
||
| 23 | * |
||
| 24 | * @param array $params |
||
| 25 | * @param null $code |
||
| 26 | * @param null $message |
||
| 27 | */ |
||
| 28 | 39 | public function __construct(array $params = [], $code = null, $message = null) |
|
| 45 | |||
| 46 | /** |
||
| 47 | * Add message parameters |
||
| 48 | * |
||
| 49 | * @param string[] $params |
||
| 50 | */ |
||
| 51 | 39 | public function addParams($params) |
|
| 55 | |||
| 56 | /** |
||
| 57 | * Build and return message |
||
| 58 | * |
||
| 59 | * @return string |
||
| 60 | */ |
||
| 61 | 38 | public function getMessage() |
|
| 65 | |||
| 66 | /** |
||
| 67 | * @return string |
||
| 68 | */ |
||
| 69 | 1 | public function getCode() |
|
| 73 | } |
||
| 74 |