@@ -59,7 +59,13 @@ $result = $builder->buildSubstring(5);
5959fwrite(STDOUT, ' 3. Built substring ' . $result . PHP_EOL);
6060
6161$result = $builder->charAt(5);
62- fwrite(STDOUT, ' 4. Character ' . $result . PHP_EOL);
62+ fwrite(STDOUT, ' 4. Character at position 5 ' . $result . PHP_EOL);
63+
64+ $result = $builder->firstChar();
65+ fwrite(STDOUT, ' 5. First character ' . $result . PHP_EOL);
66+
67+ $result = $builder->lastChar();
68+ fwrite(STDOUT, ' 6. Last character ' . $result . PHP_EOL);
6369```
6470
6571will output the following
@@ -68,44 +74,46 @@ will output the following
6874 1. Built string ä2wertzem ipsum dolor sit amet, conset
6975 2. Built substring rt
7076 3. Built substring rtzem ipsum dolor sit amet, conset
71- 4. Character r
77+ 4. Character at position 5 r
78+ 5. First character ä
79+ 6. Last character t
7280```
7381
7482### Getting string properties
7583
7684``` {php}
7785$result = $builder->length();
78- fwrite(STDOUT, ' 5 . String length ' . $result . PHP_EOL);
86+ fwrite(STDOUT, ' 7 . String length ' . $result . PHP_EOL);
7987
8088$result = $builder->size();
81- fwrite(STDOUT, ' 6 . Number of bytes ' . $result . PHP_EOL);
89+ fwrite(STDOUT, ' 8 . Number of bytes ' . $result . PHP_EOL);
8290
8391$result = $builder->indexOf('e');
84- fwrite(STDOUT, ' 7 . First occurence of "e" ' . $result . PHP_EOL);
92+ fwrite(STDOUT, ' 9 . First occurence of "e" ' . $result . PHP_EOL);
8593
8694$result = $builder->indexOf('e', 5);
87- fwrite(STDOUT, ' 8 . First occurence of "e" after position 5 ' . $result . PHP_EOL);
95+ fwrite(STDOUT, '10 . First occurence of "e" after position 5 ' . $result . PHP_EOL);
8896
8997$result = $builder->lastIndexOf('e');
90- fwrite(STDOUT, ' 9 . Last occurence of "e" ' . $result . PHP_EOL);
98+ fwrite(STDOUT, '11 . Last occurence of "e" ' . $result . PHP_EOL);
9199
92100$result = $builder->lastIndexOf('e', 5);
93- fwrite(STDOUT, '10 . Last occurence of "e" before the 5th last character ' . $result . PHP_EOL);
101+ fwrite(STDOUT, '12 . Last occurence of "e" before the 5th last character ' . $result . PHP_EOL);
94102
95103$result = $builder->contains('ipsum');
96- fwrite(STDOUT, '12 . Whether the string contains "ipsum" ' . $result . PHP_EOL);
104+ fwrite(STDOUT, '13 . Whether the string contains "ipsum" ' . $result . PHP_EOL);
97105```
98106
99107will output the following
100108
101109``` {txt}
102- 5 . String length 38
103- 6 . Number of bytes 39
104- 7 . First occurence of "e" 4
105- 8 . First occurence of "e" after position 5 8
106- 9 . Last occurence of "e" 37
107- 10 . Last occurence of "e" before the 5th last character 29
108- 12 . Whether the string contains "ipsum" <TRUE>
110+ 7 . String length 38
111+ 8 . Number of bytes 39
112+ 9 . First occurence of "e" 4
113+ 10 . First occurence of "e" after position 5 8
114+ 11 . Last occurence of "e" 37
115+ 12 . Last occurence of "e" before the 5th last character 29
116+ 13 . Whether the string contains "ipsum" <TRUE>
109117```
110118
111119### Exception handling
0 commit comments