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