| 1 | <?php |
||
| 15 | class Payload implements JsonSerializable |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var array The data from the error handler |
||
| 19 | */ |
||
| 20 | private $record; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * The data that will be send to the api. |
||
| 24 | * |
||
| 25 | * @var array |
||
| 26 | */ |
||
| 27 | private $payload; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Extra error data. |
||
| 31 | * |
||
| 32 | * @var ErrorInterface |
||
| 33 | */ |
||
| 34 | private $errorData; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Payload constructor. |
||
| 38 | * |
||
| 39 | * @param $record |
||
| 40 | */ |
||
| 41 | 3 | public function __construct(array $record) |
|
| 46 | |||
| 47 | 3 | private function generatePayload() |
|
| 53 | |||
| 54 | /** |
||
| 55 | * If available set the error data. |
||
| 56 | */ |
||
| 57 | 3 | private function setErrorData() |
|
| 58 | { |
||
| 59 | 3 | if (!isset($this->record['context']['error'])) { |
|
| 60 | 2 | return; |
|
| 61 | } |
||
| 62 | |||
| 63 | 1 | $this->errorData = $this->record['context']['error']; |
|
| 64 | 1 | } |
|
| 65 | |||
| 66 | /** |
||
| 67 | * Check if we have the extra error data. |
||
| 68 | * |
||
| 69 | * @return bool |
||
| 70 | */ |
||
| 71 | 3 | private function hasErrorData() |
|
| 75 | |||
| 76 | 3 | private function setMessage() |
|
| 84 | |||
| 85 | /** |
||
| 86 | * @inheritdoc |
||
| 87 | */ |
||
| 88 | 3 | public function jsonSerialize() |
|
| 92 | } |
||
| 93 |