@@ -158,6 +158,12 @@ Methods Related to Length and White Spaces
158
158
(new ByteString($word))->width(); // 18
159
159
(new CodePointString($word))->width(); // 4
160
160
(new UnicodeString($word))->width(); // 4
161
+ // if the text contains multiple lines, it returns the max width of all lines
162
+ $text = "<<<END
163
+ This is a
164
+ multiline text
165
+ END";
166
+ u($text)->width(); // 14
161
167
162
168
// only returns TRUE if the string is exactly an empty string (not even white spaces)
163
169
u('hello world')->isEmpty(); // false
@@ -197,7 +203,7 @@ Methods to Change Case
197
203
// other cases can be achieved by chaining methods. E.g. PascalCase:
198
204
u('Foo: Bar-baz.')->camel()->title(); // 'FooBarBaz'
199
205
200
- The methods of all string classes are case sensitive by default. You can perform
206
+ The methods of all string classes are case- sensitive by default. You can perform
201
207
case-insensitive operations with the ``ignoreCase() `` method::
202
208
203
209
u('abc')->indexOf('B'); // null
@@ -215,12 +221,15 @@ Methods to Append and Prepend
215
221
u('hello')->append('world'); // 'helloworld'
216
222
u('hello')->append(' ', 'world'); // 'hello world'
217
223
218
- // adds the given content at the beginning/end of the string, but only if not present
219
- u('Name')->ensureStart('get'); // 'getName'
220
- u('getName')->ensureStart('get'); // 'getName'
221
-
224
+ // adds the given content at the beginning of the string (or removes it) to
225
+ // make sure that the content starts exactly with that content
226
+ u('Name')->ensureStart('get'); // 'getName'
227
+ u('getName')->ensureStart('get'); // 'getName'
228
+ u('getgetName')->ensureStart('get'); // 'getName'
229
+ // this method is similar, but works on the end of the content instead of on the beginning
222
230
u('User')->ensureEnd('Controller'); // 'UserController'
223
231
u('UserController')->ensureEnd('Controller'); // 'UserController'
232
+ u('UserControllerController')->ensureEnd('Controller'); // 'UserController'
224
233
225
234
// returns the contents found before/after the first occurrence of the given string
226
235
u('hello world')->before('world'); // 'hello '
@@ -321,7 +330,7 @@ Methods to Join, Split and Truncate
321
330
u('Symfony is great')->slice(0, 7); // 'Symfony'
322
331
u('Symfony is great')->slice(0, -6); // 'Symfony is'
323
332
u('Symfony is great')->slice(11); // 'great'
324
- u('Symfony is great')->slice(-6 ); // 'great'
333
+ u('Symfony is great')->slice(-5 ); // 'great'
325
334
326
335
// reduces the string to the length given as argument (if it's longer)
327
336
u('Lorem Ipsum')->truncate(80); // 'Lorem Ipsum'
@@ -379,7 +388,7 @@ objects::
379
388
380
389
`Unicode equivalence `_ is the specification by the Unicode standard that
381
390
different sequences of code points represent the same character. For example,
382
- the Swedish ``å `` letter can be a single code point (``U+00E5 `` = *"latin small
391
+ the Swedish letter ``å `` can be a single code point (``U+00E5 `` = *"latin small
383
392
letter A with ring above" *) or a sequence of two code points (``U+0061 `` =
384
393
*"latin small letter A" * + ``U+030A `` = *"combining ring above" *). The
385
394
``normalize() `` method allows to pick the normalization mode::
0 commit comments