1 | <?php |
||
17 | class Payload implements JsonSerializable |
||
18 | { |
||
19 | /** |
||
20 | * @var array The data from the error handler |
||
21 | */ |
||
22 | private $record; |
||
23 | |||
24 | /** |
||
25 | * The data that will be send to the api. |
||
26 | * |
||
27 | * @var array |
||
28 | */ |
||
29 | private $payload; |
||
30 | |||
31 | /** |
||
32 | * Extra error data. |
||
33 | * |
||
34 | * @var ErrorInterface |
||
35 | */ |
||
36 | private $errorData; |
||
37 | |||
38 | /** |
||
39 | * Contains some extra information like channel and user etc that can be used in the payload. |
||
40 | * |
||
41 | * @var SlackConfigInterface |
||
42 | */ |
||
43 | private $slackConfig; |
||
44 | |||
45 | /** |
||
46 | * Payload constructor. |
||
47 | * |
||
48 | * @param array $record |
||
49 | * @param SlackConfigInterface $slackConfig |
||
50 | */ |
||
51 | 8 | public function __construct(array $record, SlackConfigInterface $slackConfig = null) |
|
58 | |||
59 | 8 | private function generatePayload() |
|
69 | |||
70 | /** |
||
71 | * Generate the payload for the slack config. |
||
72 | */ |
||
73 | 5 | private function generatePayloadForSlackConfig() |
|
81 | |||
82 | 3 | private function generatePayloadForCustomUser() |
|
87 | |||
88 | /** |
||
89 | * Set a custom icon if available. |
||
90 | */ |
||
91 | 3 | private function setIcon() |
|
100 | |||
101 | /** |
||
102 | * Set a custom username if available. |
||
103 | */ |
||
104 | 3 | private function setUsername() |
|
112 | |||
113 | /** |
||
114 | * Set a custom channel if available. |
||
115 | */ |
||
116 | 5 | private function setChannel() |
|
124 | |||
125 | /** |
||
126 | * If available set the error data. |
||
127 | */ |
||
128 | 8 | private function setErrorData() |
|
136 | |||
137 | 8 | private function setAttachments() |
|
143 | |||
144 | /** |
||
145 | * {@inheritdoc} |
||
146 | */ |
||
147 | 8 | public function jsonSerialize() |
|
151 | } |
||
152 |