1 | <?php |
||
20 | trait SlackMessageTrait |
||
21 | { |
||
22 | /** |
||
23 | * @param array $lines |
||
24 | * @return string |
||
25 | */ |
||
26 | 2 | public function inlineMultilines(array $lines): string |
|
30 | |||
31 | /** |
||
32 | * @param string $string |
||
33 | * @return string |
||
34 | */ |
||
35 | 1 | public function formatBold(string $string): string |
|
39 | |||
40 | /** |
||
41 | * @param string $string |
||
42 | * @return string |
||
43 | */ |
||
44 | 1 | public function formatItalic(string $string): string |
|
48 | |||
49 | /** |
||
50 | * @param string $string |
||
51 | * @return string |
||
52 | */ |
||
53 | 1 | public function formatStrikeThought(string $string): string |
|
57 | |||
58 | /** |
||
59 | * @param array $list |
||
60 | * @return string |
||
61 | * @throws \InvalidArgumentException |
||
62 | */ |
||
63 | 1 | public function formatListMarker(array $list): string |
|
64 | { |
||
65 | 1 | if (empty($list)) { |
|
66 | 1 | throw new \InvalidArgumentException('The list must contain at least one value'); |
|
67 | } |
||
68 | |||
69 | 1 | foreach ($list as $key => $value) { |
|
70 | 1 | $list[$key] = sprintf('• %s', $value); |
|
71 | } |
||
72 | |||
73 | 1 | return sprintf("\n%s\n", implode("\n", $list)); |
|
74 | } |
||
75 | |||
76 | /** |
||
77 | * @param array $list |
||
78 | * @return string |
||
79 | * @throws \InvalidArgumentException |
||
80 | */ |
||
81 | 1 | public function formatListNumeric(array $list): string |
|
82 | { |
||
83 | 1 | if (empty($list)) { |
|
84 | 1 | throw new \InvalidArgumentException('The list must contain at least one value'); |
|
85 | } |
||
86 | |||
87 | 1 | $num = 0; |
|
88 | 1 | $output = "\n"; |
|
89 | 1 | foreach ($list as $value) { |
|
90 | 1 | $output .= sprintf("%s. %s\n", ++$num, $value); |
|
91 | } |
||
92 | |||
93 | 1 | return $output; |
|
94 | } |
||
95 | |||
96 | /** |
||
97 | * @param array $lines |
||
98 | * @return string |
||
99 | */ |
||
100 | 1 | public function formatCode(array $lines): string |
|
108 | |||
109 | /** |
||
110 | * @return string |
||
111 | */ |
||
112 | 1 | public function newLine(): string |
|
116 | |||
117 | /** |
||
118 | * @param string $title |
||
119 | * @param string $url |
||
120 | * @return string |
||
121 | */ |
||
122 | 1 | public function formatLink(string $title, string $url): string |
|
126 | |||
127 | /** |
||
128 | * @param string $string |
||
129 | * @return string |
||
130 | */ |
||
131 | 10 | public function escapeCharacters(string $string): string |
|
139 | } |
||
140 |