1 | <?php |
||
24 | class SlackBot |
||
25 | { |
||
26 | const QUOTE_DEFAULT = 0; |
||
27 | const QUOTE_DANGER = 1; |
||
28 | const QUOTE_SUCCESS = 2; |
||
29 | const QUOTE_WARNING = 3; |
||
30 | const QUOTE_INFO = 4; |
||
31 | const QUOTE_MAP = [ |
||
32 | self::QUOTE_DEFAULT => 'default', |
||
33 | self::QUOTE_DANGER => 'danger', |
||
34 | self::QUOTE_SUCCESS => 'success', |
||
35 | self::QUOTE_WARNING => 'warning', |
||
36 | self::QUOTE_INFO => 'info' |
||
37 | ]; |
||
38 | |||
39 | /** @var array */ |
||
40 | private $config; |
||
41 | |||
42 | /** @var GuzzleClient */ |
||
43 | private $guzzleClient; |
||
44 | |||
45 | /** @var SlackMessageValidator */ |
||
46 | private $validator; |
||
47 | |||
48 | /** |
||
49 | * SlackBot constructor. |
||
50 | * |
||
51 | * @param array $config |
||
52 | * @param SlackMessageValidator $validator |
||
53 | */ |
||
54 | 3 | public function __construct(array $config, SlackMessageValidator $validator) |
|
60 | |||
61 | /** |
||
62 | * @return array |
||
63 | */ |
||
64 | 2 | public function getConfig(): array |
|
68 | |||
69 | /** |
||
70 | * @param array $config |
||
71 | */ |
||
72 | 3 | public function setConfig(array $config) |
|
76 | |||
77 | /** |
||
78 | * @param int $quoteType |
||
79 | * @return string |
||
80 | */ |
||
81 | 1 | public function quoteTypeColor(int $quoteType): string |
|
89 | |||
90 | /** |
||
91 | * @param SlackMessage $slackMessage |
||
92 | * @return bool |
||
93 | */ |
||
94 | public function sendMessage(SlackMessage $slackMessage): bool |
||
98 | |||
99 | /** |
||
100 | * @param SlackMessage $slackMessage |
||
101 | * @return string |
||
102 | */ |
||
103 | private function buildPostBody(SlackMessage $slackMessage): string |
||
129 | |||
130 | /** |
||
131 | * @param string $postBody |
||
132 | * @return bool |
||
133 | */ |
||
134 | private function sendRequest(string $postBody): bool |
||
143 | } |
||
144 |