|
@@ 356-365 (lines=10) @@
|
| 353 |
|
* @param string $substring The substring to add if not present |
| 354 |
|
* @return Stringy Object with its $str prefixed by the $substring |
| 355 |
|
*/ |
| 356 |
|
public function ensureLeft($substring) |
| 357 |
|
{ |
| 358 |
|
$stringy = static::create($this->str, $this->encoding); |
| 359 |
|
|
| 360 |
|
if (!$stringy->startsWith($substring)) { |
| 361 |
|
$stringy->str = $substring . $stringy->str; |
| 362 |
|
} |
| 363 |
|
|
| 364 |
|
return $stringy; |
| 365 |
|
} |
| 366 |
|
|
| 367 |
|
/** |
| 368 |
|
* Ensures that the string begins with $substring. If it doesn't, it's |
|
@@ 374-383 (lines=10) @@
|
| 371 |
|
* @param string $substring The substring to add if not present |
| 372 |
|
* @return Stringy Object with its $str suffixed by the $substring |
| 373 |
|
*/ |
| 374 |
|
public function ensureRight($substring) |
| 375 |
|
{ |
| 376 |
|
$stringy = static::create($this->str, $this->encoding); |
| 377 |
|
|
| 378 |
|
if (!$stringy->endsWith($substring)) { |
| 379 |
|
$stringy->str .= $substring; |
| 380 |
|
} |
| 381 |
|
|
| 382 |
|
return $stringy; |
| 383 |
|
} |
| 384 |
|
|
| 385 |
|
/** |
| 386 |
|
* Returns the first $n characters of the string. |