Skip to content

Commit 57f0d41

Browse files
committed
More fixes
1 parent 3f5337e commit 57f0d41

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

components/string.rst

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ Methods Related to Length and White Spaces
158158
(new ByteString($word))->width(); // 18
159159
(new CodePointString($word))->width(); // 4
160160
(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
161167

162168
// only returns TRUE if the string is exactly an empty string (not even white spaces)
163169
u('hello world')->isEmpty(); // false
@@ -197,7 +203,7 @@ Methods to Change Case
197203
// other cases can be achieved by chaining methods. E.g. PascalCase:
198204
u('Foo: Bar-baz.')->camel()->title(); // 'FooBarBaz'
199205

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
201207
case-insensitive operations with the ``ignoreCase()`` method::
202208

203209
u('abc')->indexOf('B'); // null
@@ -215,12 +221,15 @@ Methods to Append and Prepend
215221
u('hello')->append('world'); // 'helloworld'
216222
u('hello')->append(' ', 'world'); // 'hello world'
217223

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
222230
u('User')->ensureEnd('Controller'); // 'UserController'
223231
u('UserController')->ensureEnd('Controller'); // 'UserController'
232+
u('UserControllerController')->ensureEnd('Controller'); // 'UserController'
224233

225234
// returns the contents found before/after the first occurrence of the given string
226235
u('hello world')->before('world'); // 'hello '
@@ -321,7 +330,7 @@ Methods to Join, Split and Truncate
321330
u('Symfony is great')->slice(0, 7); // 'Symfony'
322331
u('Symfony is great')->slice(0, -6); // 'Symfony is'
323332
u('Symfony is great')->slice(11); // 'great'
324-
u('Symfony is great')->slice(-6); // 'great'
333+
u('Symfony is great')->slice(-5); // 'great'
325334

326335
// reduces the string to the length given as argument (if it's longer)
327336
u('Lorem Ipsum')->truncate(80); // 'Lorem Ipsum'
@@ -379,7 +388,7 @@ objects::
379388

380389
`Unicode equivalence`_ is the specification by the Unicode standard that
381390
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
383392
letter A with ring above"*) or a sequence of two code points (``U+0061`` =
384393
*"latin small letter A"* + ``U+030A`` = *"combining ring above"*). The
385394
``normalize()`` method allows to pick the normalization mode::

0 commit comments

Comments
 (0)