| @@ 2483-2497 (lines=15) @@ | ||
| 2480 | * @return static |
|
| 2481 | * <p>Object whose $str has had tabs switched to spaces.</p> |
|
| 2482 | */ |
|
| 2483 | public function toSpaces(int $tabLength = 4): self |
|
| 2484 | { |
|
| 2485 | if ($tabLength === 4) { |
|
| 2486 | $tab = ' '; |
|
| 2487 | } elseif ($tabLength === 2) { |
|
| 2488 | $tab = ' '; |
|
| 2489 | } else { |
|
| 2490 | $tab = \str_repeat(' ', $tabLength); |
|
| 2491 | } |
|
| 2492 | ||
| 2493 | return static::create( |
|
| 2494 | \str_replace("\t", $tab, $this->str), |
|
| 2495 | $this->encoding |
|
| 2496 | ); |
|
| 2497 | } |
|
| 2498 | ||
| 2499 | /** |
|
| 2500 | * Return Stringy object as string, but you can also use (string) for automatically casting the object into a |
|
| @@ 2520-2534 (lines=15) @@ | ||
| 2517 | * @return static |
|
| 2518 | * <p>Object whose $str has had spaces switched to tabs.</p> |
|
| 2519 | */ |
|
| 2520 | public function toTabs(int $tabLength = 4): self |
|
| 2521 | { |
|
| 2522 | if ($tabLength === 4) { |
|
| 2523 | $tab = ' '; |
|
| 2524 | } elseif ($tabLength === 2) { |
|
| 2525 | $tab = ' '; |
|
| 2526 | } else { |
|
| 2527 | $tab = \str_repeat(' ', $tabLength); |
|
| 2528 | } |
|
| 2529 | ||
| 2530 | return static::create( |
|
| 2531 | \str_replace($tab, "\t", $this->str), |
|
| 2532 | $this->encoding |
|
| 2533 | ); |
|
| 2534 | } |
|
| 2535 | ||
| 2536 | /** |
|
| 2537 | * Converts the first character of each word in the string to uppercase |
|