| @@ 459-468 (lines=10) @@ | ||
| 456 | * |
|
| 457 | * @return Stringy Object with its $str prefixed by the $substring |
|
| 458 | */ |
|
| 459 | public function ensureLeft($substring) |
|
| 460 | { |
|
| 461 | $stringy = static::create($this->str, $this->encoding); |
|
| 462 | ||
| 463 | if (!$stringy->startsWith($substring)) { |
|
| 464 | $stringy->str = $substring . $stringy->str; |
|
| 465 | } |
|
| 466 | ||
| 467 | return $stringy; |
|
| 468 | } |
|
| 469 | ||
| 470 | /** |
|
| 471 | * Returns true if the string begins with $substring, false otherwise. By |
|
| @@ 504-513 (lines=10) @@ | ||
| 501 | * |
|
| 502 | * @return Stringy Object with its $str suffixed by the $substring |
|
| 503 | */ |
|
| 504 | public function ensureRight($substring) |
|
| 505 | { |
|
| 506 | $stringy = static::create($this->str, $this->encoding); |
|
| 507 | ||
| 508 | if (!$stringy->endsWith($substring)) { |
|
| 509 | $stringy->str .= $substring; |
|
| 510 | } |
|
| 511 | ||
| 512 | return $stringy; |
|
| 513 | } |
|
| 514 | ||
| 515 | /** |
|
| 516 | * Returns true if the string ends with $substring, false otherwise. By |
|