1 | <?php |
||
16 | class Payload implements JsonSerializable |
||
17 | { |
||
18 | /** |
||
19 | * @var array The data from the error handler |
||
20 | */ |
||
21 | private $record; |
||
22 | |||
23 | /** |
||
24 | * The data that will be send to the api. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | private $payload; |
||
29 | |||
30 | /** |
||
31 | * Extra error data. |
||
32 | * |
||
33 | * @var ErrorInterface |
||
34 | */ |
||
35 | private $errorData; |
||
36 | |||
37 | /** |
||
38 | * Contains some extra information like channel and user etc that can be used in the payload. |
||
39 | * |
||
40 | * @var SlackConfigInterface |
||
41 | */ |
||
42 | private $slackConfig; |
||
43 | |||
44 | /** |
||
45 | * Payload constructor. |
||
46 | * |
||
47 | * @param array $record |
||
48 | * @param SlackConfigInterface $slackConfig |
||
49 | */ |
||
50 | 3 | public function __construct(array $record, SlackConfigInterface $slackConfig = null) |
|
57 | |||
58 | 3 | private function generatePayload() |
|
68 | 3 | ||
69 | /** |
||
70 | 3 | * Generate the payload for the slack config |
|
71 | 2 | */ |
|
72 | private function generatePayloadForSlackConfig() |
||
80 | |||
81 | private function generatePayloadForCustomUser() |
||
86 | |||
87 | 3 | /** |
|
88 | * Set a custom icon if available. |
||
89 | 3 | */ |
|
90 | 3 | private function setIcon() |
|
99 | 3 | ||
100 | /** |
||
101 | 3 | * Set a custom username if available. |
|
102 | */ |
||
103 | private function setUsername() |
||
111 | |||
112 | /** |
||
113 | * Set a custom channel if available. |
||
114 | */ |
||
115 | private function setChannel() |
||
123 | |||
124 | /** |
||
125 | * If available set the error data. |
||
126 | */ |
||
127 | private function setErrorData() |
||
135 | |||
136 | /** |
||
137 | * Check if we have the extra error data. |
||
138 | * |
||
139 | * @return bool |
||
140 | */ |
||
141 | private function hasErrorData() |
||
145 | |||
146 | private function setMessage() |
||
154 | |||
155 | /** |
||
156 | * @inheritdoc |
||
157 | */ |
||
158 | public function jsonSerialize() |
||
162 | } |
||
163 |