1 | <?php |
||
23 | class SlackBot |
||
24 | { |
||
25 | const QUOTE_DEFAULT = 0; |
||
26 | const QUOTE_DANGER = 1; |
||
27 | const QUOTE_SUCCESS = 2; |
||
28 | const QUOTE_WARNING = 3; |
||
29 | const QUOTE_INFO = 4; |
||
30 | const QUOTE_MAP = [ |
||
31 | self::QUOTE_DEFAULT => 'default', |
||
32 | self::QUOTE_DANGER => 'danger', |
||
33 | self::QUOTE_SUCCESS => 'success', |
||
34 | self::QUOTE_WARNING => 'warning', |
||
35 | self::QUOTE_INFO => 'info' |
||
36 | ]; |
||
37 | |||
38 | const ALLOWED_RESPONSE_STATUSES = [ |
||
39 | Response::HTTP_OK, |
||
40 | Response::HTTP_MOVED_PERMANENTLY, |
||
41 | Response::HTTP_FOUND |
||
42 | ]; |
||
43 | |||
44 | /** @var array */ |
||
45 | private $config; |
||
46 | |||
47 | /** @var GuzzleClient */ |
||
48 | private $guzzleClient; |
||
49 | |||
50 | /** @var SlackMessageValidator */ |
||
51 | private $validator; |
||
52 | |||
53 | /** |
||
54 | * @param array $config |
||
55 | * @param SlackMessageValidator $validator |
||
56 | */ |
||
57 | 3 | public function __construct(array $config, SlackMessageValidator $validator) |
|
63 | |||
64 | /** |
||
65 | * @return array |
||
66 | */ |
||
67 | 2 | public function getConfig(): array |
|
71 | |||
72 | /** |
||
73 | * @param array $config |
||
74 | */ |
||
75 | 3 | public function setConfig(array $config) |
|
79 | |||
80 | /** |
||
81 | * @param int $quoteType |
||
82 | * @return string |
||
83 | */ |
||
84 | 1 | public function quoteTypeColor(int $quoteType): string |
|
92 | |||
93 | /** |
||
94 | * @param SlackMessage $slackMessage |
||
95 | * @return bool |
||
96 | */ |
||
97 | public function sendMessage(SlackMessage $slackMessage): bool |
||
101 | |||
102 | /** |
||
103 | * @param SlackMessage $slackMessage |
||
104 | * @return string |
||
105 | */ |
||
106 | private function buildPostBody(SlackMessage $slackMessage): string |
||
141 | |||
142 | /** |
||
143 | * @param string $postBody |
||
144 | * @return bool |
||
145 | */ |
||
146 | private function sendRequest(string $postBody): bool |
||
155 | } |
||
156 |