1 | <?php |
||
10 | final class StringFormat |
||
11 | { |
||
12 | /** |
||
13 | * There are three characters you must convert to HTML entities and only three: &, <, and >. |
||
14 | * Don't HTML entity-encode the entire message, Slack will take care of the rest. |
||
15 | * This function will do that for you. |
||
16 | * |
||
17 | * @param string $unescapedText |
||
18 | * |
||
19 | * @return string |
||
20 | */ |
||
21 | 1 | public function escape($unescapedText) |
|
25 | |||
26 | /** |
||
27 | * This will emphasis the string by wrapping it between *. |
||
28 | * |
||
29 | * @param string $text |
||
30 | * |
||
31 | * @return string |
||
32 | */ |
||
33 | 7 | public function emphasis($text) |
|
37 | |||
38 | /** |
||
39 | * This will italicize the string by wrapping it between _. |
||
40 | * |
||
41 | * @param string $text |
||
42 | * |
||
43 | * @return string |
||
44 | */ |
||
45 | 1 | public function italicize($text) |
|
49 | |||
50 | /** |
||
51 | * This will strikethrough the string by wrapping it between ~. |
||
52 | * |
||
53 | * @param string $text |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | 1 | public function strikethrough($text) |
|
61 | |||
62 | /** |
||
63 | * Create a block of pre-formatted, fixed-width text. |
||
64 | * |
||
65 | * @param string $text |
||
66 | * |
||
67 | * @return string |
||
68 | */ |
||
69 | 1 | public function pre($text) |
|
73 | |||
74 | /** |
||
75 | * Display as inline fixed-width text. |
||
76 | * |
||
77 | * @param string $text |
||
78 | * |
||
79 | * @return string |
||
80 | */ |
||
81 | 1 | public function code($text) |
|
85 | |||
86 | /** |
||
87 | * Indent the text. |
||
88 | * Because multi line indenting can't be closed in slack we implemented it for you. |
||
89 | * When you use a new line it will be indented as well. |
||
90 | * |
||
91 | * @param string $text |
||
92 | * |
||
93 | * @return string |
||
94 | */ |
||
95 | 7 | public function indent($text) |
|
99 | |||
100 | /** |
||
101 | * This will generate a numbered list from an array. |
||
102 | * |
||
103 | * @param array $listItems |
||
104 | * |
||
105 | * @return string |
||
106 | */ |
||
107 | 7 | public function arrayToNumberedList(array $listItems) |
|
118 | |||
119 | /** |
||
120 | * This will generate a numbered list from an array. |
||
121 | * |
||
122 | * @param array $listItems |
||
123 | * |
||
124 | * @return string |
||
125 | */ |
||
126 | 6 | public function arrayToKeyValueList(array $listItems) |
|
136 | |||
137 | /** |
||
138 | * This will generate a bullet list from an array. |
||
139 | * |
||
140 | * @param array $listItems |
||
141 | * @param string $bulletCharacter The character used as bullet |
||
142 | * |
||
143 | * @return string |
||
144 | */ |
||
145 | 1 | public function arrayToBulletList(array $listItems, $bulletCharacter = '•') |
|
155 | |||
156 | /** |
||
157 | * Wraps a string with a wrapper string. |
||
158 | * |
||
159 | * @param string $text |
||
160 | * @param string $wrapper |
||
161 | * |
||
162 | * @return string |
||
163 | */ |
||
164 | 11 | private function wrapStringWith($text, $wrapper) |
|
168 | } |
||
169 |