1 | <?php |
||
19 | class Payload implements JsonSerializable |
||
20 | { |
||
21 | /** |
||
22 | * @var array The data from the error handler |
||
23 | */ |
||
24 | private $record; |
||
25 | |||
26 | /** |
||
27 | * The data that will be send to the api. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | private $payload; |
||
32 | |||
33 | /** |
||
34 | * Extra error data. |
||
35 | * |
||
36 | * @var ErrorInterface |
||
37 | */ |
||
38 | private $errorData; |
||
39 | |||
40 | /** |
||
41 | * Contains some extra information like channel and user etc that can be used in the payload. |
||
42 | * |
||
43 | * @var SlackConfigInterface |
||
44 | */ |
||
45 | private $slackConfig; |
||
46 | |||
47 | /** |
||
48 | * Payload constructor. |
||
49 | * |
||
50 | * @param array $record |
||
51 | * @param SlackConfigInterface $slackConfig |
||
52 | */ |
||
53 | 8 | public function __construct(array $record, SlackConfigInterface $slackConfig = null) |
|
60 | |||
61 | 8 | private function generatePayload() |
|
71 | |||
72 | /** |
||
73 | * Generate the payload for the slack config. |
||
74 | */ |
||
75 | 5 | private function generatePayloadForSlackConfig() |
|
83 | |||
84 | 3 | private function generatePayloadForCustomUser() |
|
89 | |||
90 | /** |
||
91 | * Set a custom icon if available. |
||
92 | */ |
||
93 | 3 | private function setIcon() |
|
102 | |||
103 | /** |
||
104 | * Set a custom username if available. |
||
105 | */ |
||
106 | 3 | private function setUsername() |
|
114 | |||
115 | /** |
||
116 | * Set a custom channel if available. |
||
117 | */ |
||
118 | 5 | private function setChannel() |
|
126 | |||
127 | /** |
||
128 | * If available set the error data. |
||
129 | */ |
||
130 | 8 | private function setErrorData() |
|
141 | |||
142 | 8 | private function setAttachments() |
|
152 | |||
153 | 6 | private function addErrorSpecificAttachments() |
|
159 | |||
160 | /** |
||
161 | * {@inheritdoc} |
||
162 | */ |
||
163 | 8 | public function jsonSerialize() |
|
167 | |||
168 | /** |
||
169 | * {@inheritdoc} |
||
170 | */ |
||
171 | 2 | public function __toString() |
|
175 | } |
||
176 |