1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-09-02 09:33:10 +02:00

Added truncate()

This commit is contained in:
Daniel St. Jules
2013-07-27 15:39:36 -04:00
parent 77ae682de1
commit 4828811a48
6 changed files with 104 additions and 7 deletions

View File

@@ -32,6 +32,7 @@ Note: The methods listed below are subject to change until we reach a 1.0.0 rele
* [contains](#contains)
* [surround](#surround)
* [insert](#insert)
* [truncate](#truncate)
* [safeTruncate](#safetruncate)
* [reverse](#reverse)
* [shuffle](#shuffle)
@@ -467,6 +468,21 @@ S::create('fòô bà', 'UTF-8')->insert('ř', 6);
S::insert('fòô bà', 'ř', 6, 'UTF-8'); // 'fòô bàř'
```
##### truncate
$stringy->truncate(int $length, [, string $substring = '' ])
S::truncate(string $str, int $length, [, string $substring = '' [, string $encoding ]])
Truncates $str to a given length. If $substring is provided, and
truncating occurs, the string is further truncated so that the substring
may be appended without exceeding the desired length.
```php
S::create('What are your plans today?')->safeTruncate(19, '...');
S::safeTruncate('What are your plans today?', 19, '...'); // 'What are your pl...'
```
##### safeTruncate
$stringy->safeTruncate(int $length, [, string $substring = '' ])
@@ -650,8 +666,6 @@ S::last('fòô bàř', 3, 'UTF-8'); // 'bàř'
**excerpt** ($str, $substring, $radius)
**truncate**
**pluralize** ($count, $singular, $plural = null)
**toBoolean**