File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 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)
261261 return mb_substr ($ this ->string , $ position , 1 );
262262 }
263263
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+
264284 /**
265285 * Returns an substring defined by startPosition and length
266286 *
Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ public function testBuilder()
3939 $ this ->assertEquals (9 , $ builder ->lastIndexOf ('e ' ));
4040 $ this ->assertNull ($ builder ->lastIndexOf ('e ' ,10 ));
4141 $ this ->assertTrue ($ builder ->contains ('21b ' ));
42+ $ this ->assertEquals ('b ' , $ builder ->firstChar ());
43+ $ this ->assertEquals ('ö ' , $ builder ->lastChar ());
4244 $ this ->assertFalse ($ builder ->contains ('abc ' ));
4345 $ this ->assertEquals ('öeb1212ewqb ' , $ builder ->reverse ()->build ());
4446 $ builder = new StringBuilder ('0123456 ' );
You can’t perform that action at this time.
0 commit comments