mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-09-01 09:03:03 +02:00
Added ensureLeft() and ensureRight()
This commit is contained in:
46
README.md
46
README.md
@@ -44,6 +44,8 @@ Note: The methods listed below are subject to change until we reach a 1.0.0 rele
|
||||
* [at](#at)
|
||||
* [first](#first)
|
||||
* [last](#last)
|
||||
* [ensureLeft](#ensureLeft)
|
||||
* [ensureRight](#ensureRight)
|
||||
* [Tests](#tests)
|
||||
* [License](#license)
|
||||
|
||||
@@ -646,34 +648,46 @@ S::create('fòô bàř', 'UTF-8')->last(3);
|
||||
S::last('fòô bàř', 3, 'UTF-8'); // 'bàř'
|
||||
```
|
||||
|
||||
##### ensureLeft
|
||||
|
||||
$stringy->ensureLeft(string $substring)
|
||||
|
||||
S::ensureLeft(string $substring [, string $encoding ])
|
||||
|
||||
Ensures that $str begins with $substring.
|
||||
|
||||
```php
|
||||
S::create('foobar')->ensureLeft('http://');
|
||||
S::ensureLeft('foobar', 'http://'); // 'http://foobar'
|
||||
```
|
||||
|
||||
##### ensureRight
|
||||
|
||||
$stringy->ensureRight(string $substring)
|
||||
|
||||
S::ensureRight(string $substring [, string $encoding ])
|
||||
|
||||
Ensures that $str ends with $substring.
|
||||
|
||||
```php
|
||||
S::create('foobar')->ensureRight('.com');
|
||||
S::ensureRight('foobar', '.com'); // 'foobar.com'
|
||||
```
|
||||
|
||||
## TODO
|
||||
|
||||
**count** => substr_count
|
||||
|
||||
**wordCount** => str_word_count
|
||||
|
||||
**isMultibyte**
|
||||
|
||||
**wordWrap**
|
||||
|
||||
**chars** $callback
|
||||
|
||||
**words** $callback
|
||||
|
||||
**paragraphs**
|
||||
|
||||
**lines**
|
||||
|
||||
**excerpt** ($str, $substring, $radius)
|
||||
|
||||
**pluralize** ($count, $singular, $plural = null)
|
||||
|
||||
**toBoolean**
|
||||
|
||||
**ensureLeft**
|
||||
|
||||
**ensureRight**
|
||||
|
||||
**isAlpha**
|
||||
|
||||
**isAlphaNumeric**
|
||||
@@ -684,6 +698,10 @@ S::last('fòô bàř', 3, 'UTF-8'); // 'bàř'
|
||||
|
||||
**isBlank**
|
||||
|
||||
**chompLeft**
|
||||
|
||||
**chompRight**
|
||||
|
||||
## Tests
|
||||
|
||||
[](https://travis-ci.org/danielstjules/Stringy)
|
||||
|
Reference in New Issue
Block a user