1 | <?php |
||
18 | class Payload implements JsonSerializable |
||
19 | { |
||
20 | /** |
||
21 | * @var array The data from the error handler |
||
22 | */ |
||
23 | private $record; |
||
24 | |||
25 | /** |
||
26 | * The data that will be send to the api. |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | private $payload; |
||
31 | |||
32 | /** |
||
33 | * Extra error data. |
||
34 | * |
||
35 | * @var ErrorInterface |
||
36 | */ |
||
37 | private $errorData; |
||
38 | |||
39 | /** |
||
40 | * Contains some extra information like channel and user etc that can be used in the payload. |
||
41 | * |
||
42 | * @var SlackConfigInterface |
||
43 | */ |
||
44 | private $slackConfig; |
||
45 | |||
46 | /** |
||
47 | * Payload constructor. |
||
48 | * |
||
49 | * @param array $record |
||
50 | * @param SlackConfigInterface $slackConfig |
||
51 | */ |
||
52 | 8 | public function __construct(array $record, SlackConfigInterface $slackConfig = null) |
|
59 | |||
60 | 8 | private function generatePayload() |
|
70 | |||
71 | /** |
||
72 | * Generate the payload for the slack config. |
||
73 | */ |
||
74 | 5 | private function generatePayloadForSlackConfig() |
|
82 | |||
83 | 3 | private function generatePayloadForCustomUser() |
|
88 | |||
89 | /** |
||
90 | * Set a custom icon if available. |
||
91 | */ |
||
92 | 3 | private function setIcon() |
|
101 | |||
102 | /** |
||
103 | * Set a custom username if available. |
||
104 | */ |
||
105 | 3 | private function setUsername() |
|
113 | |||
114 | /** |
||
115 | * Set a custom channel if available. |
||
116 | */ |
||
117 | 5 | private function setChannel() |
|
125 | |||
126 | /** |
||
127 | * If available set the error data. |
||
128 | */ |
||
129 | 8 | private function setErrorData() |
|
137 | |||
138 | 8 | private function setAttachments() |
|
148 | |||
149 | 6 | private function addErrorSpecificAttachments() |
|
154 | |||
155 | /** |
||
156 | * {@inheritdoc} |
||
157 | */ |
||
158 | 8 | public function jsonSerialize() |
|
162 | |||
163 | /** |
||
164 | * @inheritDoc |
||
165 | */ |
||
166 | 2 | public function __toString() |
|
170 | } |
||
171 |