| @@ 467-476 (lines=10) @@ | ||
| 464 | * |
|
| 465 | * @return static Object with its $str prefixed by the $substring |
|
| 466 | */ |
|
| 467 | public function ensureLeft($substring) |
|
| 468 | { |
|
| 469 | $stringy = static::create($this->str, $this->encoding); |
|
| 470 | ||
| 471 | if (!$stringy->startsWith($substring)) { |
|
| 472 | $stringy->str = $substring . $stringy->str; |
|
| 473 | } |
|
| 474 | ||
| 475 | return $stringy; |
|
| 476 | } |
|
| 477 | ||
| 478 | /** |
|
| 479 | * Returns true if the string begins with $substring, false otherwise. By |
|
| @@ 533-542 (lines=10) @@ | ||
| 530 | * |
|
| 531 | * @return static Object with its $str suffixed by the $substring |
|
| 532 | */ |
|
| 533 | public function ensureRight($substring) |
|
| 534 | { |
|
| 535 | $stringy = static::create($this->str, $this->encoding); |
|
| 536 | ||
| 537 | if (!$stringy->endsWith($substring)) { |
|
| 538 | $stringy->str .= $substring; |
|
| 539 | } |
|
| 540 | ||
| 541 | return $stringy; |
|
| 542 | } |
|
| 543 | ||
| 544 | /** |
|
| 545 | * Returns true if the string ends with $substring, false otherwise. By |
|