| @@ 482-491 (lines=10) @@ | ||
| 479 | * |
|
| 480 | * @return static Object with its $str prefixed by the $substring |
|
| 481 | */ |
|
| 482 | public function ensureLeft($substring) |
|
| 483 | { |
|
| 484 | $stringy = static::create($this->str, $this->encoding); |
|
| 485 | ||
| 486 | if (!$stringy->startsWith($substring)) { |
|
| 487 | $stringy->str = $substring . $stringy->str; |
|
| 488 | } |
|
| 489 | ||
| 490 | return $stringy; |
|
| 491 | } |
|
| 492 | ||
| 493 | /** |
|
| 494 | * Returns true if the string begins with $substring, false otherwise. By |
|
| @@ 548-557 (lines=10) @@ | ||
| 545 | * |
|
| 546 | * @return static Object with its $str suffixed by the $substring |
|
| 547 | */ |
|
| 548 | public function ensureRight($substring) |
|
| 549 | { |
|
| 550 | $stringy = static::create($this->str, $this->encoding); |
|
| 551 | ||
| 552 | if (!$stringy->endsWith($substring)) { |
|
| 553 | $stringy->str .= $substring; |
|
| 554 | } |
|
| 555 | ||
| 556 | return $stringy; |
|
| 557 | } |
|
| 558 | ||
| 559 | /** |
|
| 560 | * Returns true if the string ends with $substring, false otherwise. By |
|