1 | <?php namespace Gears\String; |
||
38 | class Builder implements Comparable |
||
39 | { |
||
40 | /** |
||
41 | * The string that this builder is building. |
||
42 | * |
||
43 | * @var \Gears\String\Str |
||
44 | */ |
||
45 | protected $str; |
||
46 | |||
47 | /** |
||
48 | * After building your string, you may retreive the underlying Str object. |
||
49 | * |
||
50 | * @return \Gears\String\Str |
||
51 | */ |
||
52 | public function getStr() |
||
56 | |||
57 | /** |
||
58 | * String Builder Constructor. |
||
59 | * |
||
60 | * @param string|Str $string Optionally provide an intial string. |
||
61 | * |
||
62 | * @param string|null $encoding The character encoding to use for this |
||
63 | * string builder. If not specified, defaults |
||
64 | * to the value returned from |
||
65 | * mb_internal_encoding(). |
||
66 | */ |
||
67 | public function __construct($string = '', $encoding = null) |
||
80 | |||
81 | /** |
||
82 | * Magic method to automatically turn the builder back into a scalar string. |
||
83 | * |
||
84 | * @see http://php.net/manual/en/language.oop5.magic.php#object.tostring |
||
85 | * |
||
86 | * @return string |
||
87 | */ |
||
88 | public function __toString() |
||
92 | |||
93 | /** |
||
94 | * Appends a copy of the specified string to this instance. |
||
95 | * |
||
96 | * @param string|Str $string The string to append. |
||
97 | * |
||
98 | * @return static |
||
99 | */ |
||
100 | public function append($string) |
||
129 | |||
130 | /** |
||
131 | * Appends the string returned by vsprintf given the $format and $args. |
||
132 | * |
||
133 | * For details on the syntax of the $format string: |
||
134 | * @see http://php.net/manual/en/function.sprintf.php |
||
135 | * |
||
136 | * @param string|Str $format The format string is composed of zero or more |
||
137 | * directives: ordinary characters (excluding %) |
||
138 | * that are copied directly to the result, and |
||
139 | * conversion specifications. |
||
140 | * |
||
141 | * @param array $args The arguments that will be inserted |
||
142 | * into the $format string. |
||
143 | * |
||
144 | * @return static |
||
145 | */ |
||
146 | public function appendFormat($format, $args) |
||
150 | |||
151 | /** |
||
152 | * Appends the default line terminator to the end of the current Builder. |
||
153 | * |
||
154 | * @param string|Str $string Optional, a string to append before |
||
155 | * the line terminator. |
||
156 | * |
||
157 | * @param string|Str $type The line terminator to append, |
||
158 | * defaults to LINE FEED. |
||
159 | * |
||
160 | * @return static |
||
161 | */ |
||
162 | public function appendLine($string = '', $type = "\n") |
||
166 | |||
167 | /** |
||
168 | * Removes all characters from the current Builder instance. |
||
169 | * |
||
170 | * @return static |
||
171 | */ |
||
172 | public function clear() |
||
178 | |||
179 | /** |
||
180 | * Implements Icecave\Parity\SubClassComparableInterface compare method. |
||
181 | * |
||
182 | * @see https://git.io/vVxSz |
||
183 | * |
||
184 | * @param object $value The object to compare. |
||
185 | * |
||
186 | * @return integer The result of the comparison. |
||
187 | */ |
||
188 | public function compare($value) |
||
192 | |||
193 | /** |
||
194 | * Returns a value indicating whether this instance is equal to another. |
||
195 | * |
||
196 | * @param object $value The object to compare. |
||
197 | * |
||
198 | * @return boolean |
||
199 | */ |
||
200 | public function equals($value) |
||
204 | |||
205 | /** |
||
206 | * Inserts a string into this instance at the specified character position. |
||
207 | * |
||
208 | * @param int $index The index at which to insert the substring. |
||
209 | * |
||
210 | * @param string|Str $string The substring to insert. |
||
211 | * |
||
212 | * @return static |
||
213 | */ |
||
214 | public function insert($index, $string) |
||
223 | |||
224 | /** |
||
225 | * Removes the specified range of characters from this instance. |
||
226 | * |
||
227 | * @param int $startIndex The zero-based position in this instance |
||
228 | * where removal begins. |
||
229 | * |
||
230 | * @param int $length The number of characters to remove. |
||
231 | * |
||
232 | * @return static |
||
233 | */ |
||
234 | public function remove($startIndex, $length) |
||
256 | |||
257 | /** |
||
258 | * Replaces all occurrences of $old in this instance with $new. |
||
259 | * |
||
260 | * @param string|Str $old The string to replace. |
||
261 | * |
||
262 | * @param string|Str $new The string that replaces $old. |
||
263 | * |
||
264 | * @return static |
||
265 | */ |
||
266 | public function replace($old, $new) |
||
272 | } |
||
273 |