| @@ 397-406 (lines=10) @@ | ||
| 394 | * |
|
| 395 | * @return Stringy Object with its $str prefixed by the $substring |
|
| 396 | */ |
|
| 397 | public function ensureLeft($substring) |
|
| 398 | { |
|
| 399 | $stringy = static::create($this->str, $this->encoding); |
|
| 400 | ||
| 401 | if (!$stringy->startsWith($substring)) { |
|
| 402 | $stringy->str = $substring . $stringy->str; |
|
| 403 | } |
|
| 404 | ||
| 405 | return $stringy; |
|
| 406 | } |
|
| 407 | ||
| 408 | /** |
|
| 409 | * Returns true if the string begins with $substring, false otherwise. By |
|
| @@ 442-451 (lines=10) @@ | ||
| 439 | * |
|
| 440 | * @return Stringy Object with its $str suffixed by the $substring |
|
| 441 | */ |
|
| 442 | public function ensureRight($substring) |
|
| 443 | { |
|
| 444 | $stringy = static::create($this->str, $this->encoding); |
|
| 445 | ||
| 446 | if (!$stringy->endsWith($substring)) { |
|
| 447 | $stringy->str .= $substring; |
|
| 448 | } |
|
| 449 | ||
| 450 | return $stringy; |
|
| 451 | } |
|
| 452 | ||
| 453 | /** |
|
| 454 | * Returns true if the string ends with $substring, false otherwise. By |
|