File tree 2 files changed +22
-0
lines changed
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -261,6 +261,26 @@ public function charAt($position)
261
261
return mb_substr ($ this ->string , $ position , 1 );
262
262
}
263
263
264
+ /**
265
+ * Returns first character
266
+ *
267
+ * @return string
268
+ */
269
+ public function firstChar ()
270
+ {
271
+ return mb_substr ($ this ->string , 0 , 1 );
272
+ }
273
+
274
+ /**
275
+ * Returns last character
276
+ *
277
+ * @return string
278
+ */
279
+ public function lastChar ()
280
+ {
281
+ return mb_substr ($ this ->string , -1 );
282
+ }
283
+
264
284
/**
265
285
* Returns an substring defined by startPosition and length
266
286
*
Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ public function testBuilder()
39
39
$ this ->assertEquals (9 , $ builder ->lastIndexOf ('e ' ));
40
40
$ this ->assertNull ($ builder ->lastIndexOf ('e ' ,10 ));
41
41
$ this ->assertTrue ($ builder ->contains ('21b ' ));
42
+ $ this ->assertEquals ('b ' , $ builder ->firstChar ());
43
+ $ this ->assertEquals ('ö ' , $ builder ->lastChar ());
42
44
$ this ->assertFalse ($ builder ->contains ('abc ' ));
43
45
$ this ->assertEquals ('öeb1212ewqb ' , $ builder ->reverse ()->build ());
44
46
$ builder = new StringBuilder ('0123456 ' );
You can’t perform that action at this time.
0 commit comments