1 | <?php |
||
14 | final class StringFormat |
||
15 | { |
||
16 | /** |
||
17 | * There are three characters you must convert to HTML entities and only three: &, <, and >. |
||
18 | * Don't HTML entity-encode the entire message, Slack will take care of the rest. |
||
19 | * This function will do that for you. |
||
20 | * |
||
21 | * @param string $unescapedText |
||
22 | * |
||
23 | * @return string |
||
24 | */ |
||
25 | 1 | public function escape($unescapedText) |
|
29 | |||
30 | /** |
||
31 | * This will emphasis the string by wrapping it between * |
||
32 | * |
||
33 | * @param string $text |
||
34 | * |
||
35 | * @return string |
||
36 | */ |
||
37 | 7 | public function emphasis($text) |
|
41 | |||
42 | /** |
||
43 | * This will italicize the string by wrapping it between _ |
||
44 | * |
||
45 | * @param string $text |
||
46 | * |
||
47 | * @return string |
||
48 | */ |
||
49 | 1 | public function italicize($text) |
|
53 | |||
54 | /** |
||
55 | * This will strikethrough the string by wrapping it between ~ |
||
56 | * |
||
57 | * @param string $text |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | 1 | public function strikethrough($text) |
|
65 | |||
66 | /** |
||
67 | * Create a block of pre-formatted, fixed-width text |
||
68 | * |
||
69 | * @param string $text |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | 1 | public function pre($text) |
|
77 | |||
78 | /** |
||
79 | * Display as inline fixed-width text. |
||
80 | * |
||
81 | * @param string $text |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | 1 | public function code($text) |
|
89 | |||
90 | /** |
||
91 | * Indent the text. |
||
92 | * Because multi line indenting can't be closed in slack we implemented it for you. |
||
93 | * When you use a new line it will be indented as well. |
||
94 | * |
||
95 | * @param string $text |
||
96 | * |
||
97 | * @return string |
||
98 | */ |
||
99 | 7 | public function indent($text) |
|
103 | |||
104 | /** |
||
105 | * This will generate a numbered list from an array. |
||
106 | * |
||
107 | * @param array $listItems |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | 7 | public function arrayToNumberedList(array $listItems) |
|
122 | |||
123 | /** |
||
124 | * This will generate a numbered list from an array. |
||
125 | * |
||
126 | * @param array $listItems |
||
127 | * |
||
128 | * @return string |
||
129 | */ |
||
130 | 6 | public function arrayToKeyValueList(array $listItems) |
|
140 | |||
141 | /** |
||
142 | * This will generate a bullet list from an array. |
||
143 | * |
||
144 | * @param array $listItems |
||
145 | * @param string $bulletCharacter The character used as bullet |
||
146 | * |
||
147 | * @return string |
||
148 | */ |
||
149 | 1 | public function arrayToBulletList(array $listItems, $bulletCharacter = '•') |
|
159 | |||
160 | /** |
||
161 | * Wraps a string with a wrapper string. |
||
162 | * |
||
163 | * @param string $text |
||
164 | * @param string $wrapper |
||
165 | * |
||
166 | * @return string |
||
167 | */ |
||
168 | 11 | private function wrapStringWith($text, $wrapper) |
|
172 | } |
||
173 |