1
0
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:
Daniel St. Jules
2013-07-27 16:33:27 -04:00
parent 4828811a48
commit 6d927fbf5d
6 changed files with 156 additions and 14 deletions

View File

@@ -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
[![Build Status](https://travis-ci.org/danielstjules/Stringy.png)](https://travis-ci.org/danielstjules/Stringy)