1 | <?php |
||
12 | class JString |
||
13 | { |
||
14 | /* |
||
15 | * @var string |
||
16 | */ |
||
17 | private $value; |
||
18 | |||
19 | /** |
||
20 | * @param string $str |
||
21 | */ |
||
22 | 11 | public function __construct(string $str) |
|
26 | |||
27 | /** |
||
28 | * @return string |
||
29 | */ |
||
30 | 1 | public function getValue() : string |
|
34 | |||
35 | /** |
||
36 | * Compares this string to the specified object. The result is true if and only if the |
||
37 | * argument is not null and is a string that represents the same sequence of |
||
38 | * characters as this object. |
||
39 | * |
||
40 | * @param string $stringToCompare |
||
41 | * @return bool |
||
42 | */ |
||
43 | 2 | public function equals(string $stringToCompare) : bool |
|
47 | |||
48 | /** |
||
49 | * Compares this string to another string, ignoring case considerations. |
||
50 | * Two strings are considered equal ignoring case if they are of the same length |
||
51 | * and corresponding characters in the two strings are equal ignoring case. |
||
52 | * |
||
53 | * Two characters c1 and c2 are considered the same ignoring case if at least one of the |
||
54 | * following is true: |
||
55 | * The two characters are the same (as compared by the == operator) |
||
56 | * Applying the method JString.toUpperCase(char) to each character produces the same result |
||
57 | * Applying the method JString.toLowerCase(char) to each character produces the same result |
||
58 | * Returns: |
||
59 | * true if the argument is not null and it represents an equivalent JString ignoring case; |
||
60 | * false otherwise |
||
61 | * |
||
62 | * @param string $anotherString |
||
63 | * @return bool |
||
64 | */ |
||
65 | 3 | public function equalsIgnoreCase($anotherString) : bool |
|
69 | |||
70 | /** |
||
71 | * Returns the length of the sequence of characters represented by this object. |
||
72 | * |
||
73 | * @return int |
||
74 | */ |
||
75 | 2 | public function length() : int |
|
79 | |||
80 | /** |
||
81 | * Concatenates the specified string to the end of this string. |
||
82 | * If the length of the argument string is 0, then a string is returned. |
||
83 | * Otherwise, a new string is created, representing a character sequence that |
||
84 | * is the concatenation of the character sequence represented by this JString object and |
||
85 | * the character sequence represented by the argument string. |
||
86 | * returns: |
||
87 | * A string that represents the concatenation of this object's characters followed by the |
||
88 | * string argument characters. |
||
89 | * |
||
90 | * @param string $str |
||
91 | * @return string |
||
92 | */ |
||
93 | 1 | public function concat($str) |
|
101 | |||
102 | /** |
||
103 | * Returns true if and only if this string contains the specified sequence of char values. |
||
104 | * false otherwise |
||
105 | * |
||
106 | * @param string $str |
||
107 | * @throws \InvalidArgumentException |
||
108 | * @return bool |
||
109 | */ |
||
110 | 2 | public function contains(string $str) : bool |
|
114 | |||
115 | /** |
||
116 | * Returns true if the string ends with $substring, false otherwise. By |
||
117 | * default, the comparison is case-sensitive, but can be made insensitive |
||
118 | * by setting $caseSensitive to false. |
||
119 | * |
||
120 | * @param string $suffix |
||
121 | * @param bool $caseSensitive |
||
122 | * @return bool |
||
123 | */ |
||
124 | 1 | public function endsWith($suffix, $caseSensitive = true) |
|
138 | |||
139 | /** |
||
140 | * Tests if the substring of this string beginning at the specified index starts |
||
141 | * with the specified prefix. |
||
142 | * Returns: |
||
143 | * true if the character sequence represented by the argument is a prefix of the substring of |
||
144 | * this object starting at index toOffset; false otherwise. The result is false if toOffset |
||
145 | * is negative or greater than the length of this JString Object |
||
146 | * |
||
147 | * @param string $prefix |
||
148 | * @param int $toOffset |
||
149 | * @return bool |
||
150 | */ |
||
151 | 1 | public function startsWith($prefix, $toOffset = 0) |
|
160 | |||
161 | /** |
||
162 | * Returns the char value at the specified index. An index ranges from 0 to length() - 1. |
||
163 | * The first char value of the sequence is at index 0, the next at index 1, and so on, |
||
164 | * as for array indexing. If the char value specified by the index is a surrogate, |
||
165 | * the surrogate value is returned. |
||
166 | * |
||
167 | * @param int $index |
||
168 | * @throws IndexOutOfBoundsException |
||
169 | * @return string |
||
170 | */ |
||
171 | 1 | public function charAt($index) |
|
181 | |||
182 | /** |
||
183 | * Returns the index within this string of the first occurrence of the specified character. |
||
184 | * If the argument fromIndex is specified the search will start at the index that was informed |
||
185 | * |
||
186 | * @param string $char |
||
187 | * @param int $fromIndex |
||
188 | * @return int positive with the position of desired part of the string, -1 if the string not found |
||
189 | */ |
||
190 | 1 | public function indexOf($char, $fromIndex = 0) |
|
199 | |||
200 | /** |
||
201 | * Returns the index within this string of the last occurrence of the specified character. |
||
202 | * If you set the fromIndex argument the method will searching backward starting at the specified index. |
||
203 | * |
||
204 | * @param string $char |
||
205 | * @param int $fromIndex |
||
206 | * @return int |
||
207 | */ |
||
208 | 1 | public function lastIndexOf($char, $fromIndex = -1) |
|
217 | |||
218 | /** |
||
219 | * Returns true if, and only if, length() is 0. |
||
220 | * |
||
221 | * @return bool |
||
222 | */ |
||
223 | 1 | public function isEmpty() |
|
227 | |||
228 | /** |
||
229 | * Splits this string around matches of the given regular expression. |
||
230 | * |
||
231 | * @param string $char |
||
232 | * @return array |
||
233 | */ |
||
234 | 1 | public function split($char) |
|
238 | |||
239 | /** |
||
240 | * Converts all of the characters in this JString to lower case using the rules |
||
241 | * of the default locale. |
||
242 | * |
||
243 | * @return string |
||
244 | */ |
||
245 | 1 | public function toLowerCase() |
|
249 | |||
250 | /** |
||
251 | * Converts all of the characters in this JString to upper case using the rules |
||
252 | * of the default locale. |
||
253 | * |
||
254 | * @return string |
||
255 | */ |
||
256 | 1 | public function toUpperCase() |
|
260 | |||
261 | /** |
||
262 | * Returns a copy of the string, with leading and trailing whitespace omitted. |
||
263 | * |
||
264 | * @return string |
||
265 | */ |
||
266 | 1 | public function trim() |
|
270 | |||
271 | /** |
||
272 | * Returns a new string that is a substring of this string. The substring begins at |
||
273 | * the specified beginIndex and extends to the character at index endIndex - 1. |
||
274 | * Thus the length of the substring is endIndex-beginIndex. |
||
275 | * |
||
276 | * @param int $beginIndex |
||
277 | * @param int $endIndex |
||
278 | * @return string |
||
279 | */ |
||
280 | 1 | public function substring($beginIndex, $endIndex = -1) |
|
288 | |||
289 | /** |
||
290 | * Returns a new string resulting from replacing all occurrences of |
||
291 | * oldChar in this string with newChar. |
||
292 | * |
||
293 | * @param string $oldChar |
||
294 | * @param string $newChar |
||
295 | * @return string |
||
296 | */ |
||
297 | 1 | public function replace($oldChar, $newChar) |
|
301 | |||
302 | /** |
||
303 | * The string value (which is already a string!) is itself returned. |
||
304 | * |
||
305 | * @return string |
||
306 | */ |
||
307 | 1 | public function __toString() |
|
311 | } |
||
312 |