1 | <?php |
||
7 | class Ansi extends Parser |
||
8 | { |
||
9 | /** |
||
10 | * Wrap the string in the current style |
||
11 | * |
||
12 | * @param string $str |
||
13 | * |
||
14 | * @return string |
||
15 | */ |
||
16 | |||
17 | 556 | public function apply($str) |
|
21 | |||
22 | /** |
||
23 | * Get the string that begins the style |
||
24 | * |
||
25 | * @param string $codes |
||
26 | * @return string |
||
27 | */ |
||
28 | 556 | protected function start($codes = null) |
|
35 | |||
36 | /** |
||
37 | * Get the string that ends the style |
||
38 | * |
||
39 | * @param string|array $codes |
||
40 | * @return string |
||
41 | */ |
||
42 | 556 | protected function end($codes = null) |
|
55 | |||
56 | /** |
||
57 | * Wrap the code string in the full escaped sequence |
||
58 | * |
||
59 | * @param string $codes |
||
60 | * |
||
61 | * @return string |
||
62 | */ |
||
63 | |||
64 | 556 | protected function wrapCodes($codes) |
|
68 | |||
69 | /** |
||
70 | * Parse the string for tags and replace them with their codes |
||
71 | * |
||
72 | * @param string $str |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | |||
77 | 556 | protected function parse($str) |
|
91 | |||
92 | /** |
||
93 | * Parse the given string for the tags and replace them with the appropriate codes |
||
94 | * |
||
95 | * @param string $str |
||
96 | * @param array $tags |
||
97 | * |
||
98 | * @return string |
||
99 | */ |
||
100 | |||
101 | 72 | protected function parseTags($str, $tags) |
|
112 | |||
113 | /** |
||
114 | * Replace the tag in the str |
||
115 | * |
||
116 | * @param string $str |
||
117 | * @param string $tag |
||
118 | * @param array $history |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | |||
123 | 72 | protected function replaceTag($str, $tag, &$history) |
|
140 | |||
141 | /** |
||
142 | * Stringify the codes |
||
143 | * |
||
144 | * @param mixed $codes |
||
145 | * |
||
146 | * @return string |
||
147 | */ |
||
148 | |||
149 | 556 | protected function codeStr($codes) |
|
163 | |||
164 | /** |
||
165 | * Retrieve the current style code |
||
166 | * |
||
167 | * @return string |
||
168 | */ |
||
169 | |||
170 | 556 | protected function currentCode() |
|
174 | } |
||
175 |