| @@ 461-470 (lines=10) @@ | ||
| 458 | * |
|
| 459 | * @return Stringy Object with its $str prefixed by the $substring |
|
| 460 | */ |
|
| 461 | public function ensureLeft($substring) |
|
| 462 | { |
|
| 463 | $stringy = static::create($this->str, $this->encoding); |
|
| 464 | ||
| 465 | if (!$stringy->startsWith($substring)) { |
|
| 466 | $stringy->str = $substring . $stringy->str; |
|
| 467 | } |
|
| 468 | ||
| 469 | return $stringy; |
|
| 470 | } |
|
| 471 | ||
| 472 | /** |
|
| 473 | * Returns true if the string begins with $substring, false otherwise. By |
|
| @@ 527-536 (lines=10) @@ | ||
| 524 | * |
|
| 525 | * @return Stringy Object with its $str suffixed by the $substring |
|
| 526 | */ |
|
| 527 | public function ensureRight($substring) |
|
| 528 | { |
|
| 529 | $stringy = static::create($this->str, $this->encoding); |
|
| 530 | ||
| 531 | if (!$stringy->endsWith($substring)) { |
|
| 532 | $stringy->str .= $substring; |
|
| 533 | } |
|
| 534 | ||
| 535 | return $stringy; |
|
| 536 | } |
|
| 537 | ||
| 538 | /** |
|
| 539 | * Returns true if the string ends with $substring, false otherwise. By |
|