| @@ 2498-2512 (lines=15) @@ | ||
| 2495 | * @return static |
|
| 2496 | * <p>Object whose $str has had tabs switched to spaces.</p> |
|
| 2497 | */ |
|
| 2498 | public function toSpaces(int $tabLength = 4): self |
|
| 2499 | { |
|
| 2500 | if ($tabLength === 4) { |
|
| 2501 | $tab = ' '; |
|
| 2502 | } elseif ($tabLength === 2) { |
|
| 2503 | $tab = ' '; |
|
| 2504 | } else { |
|
| 2505 | $tab = \str_repeat(' ', $tabLength); |
|
| 2506 | } |
|
| 2507 | ||
| 2508 | return static::create( |
|
| 2509 | \str_replace("\t", $tab, $this->str), |
|
| 2510 | $this->encoding |
|
| 2511 | ); |
|
| 2512 | } |
|
| 2513 | ||
| 2514 | /** |
|
| 2515 | * Return Stringy object as string, but you can also use (string) for automatically casting the object into a |
|
| @@ 2535-2549 (lines=15) @@ | ||
| 2532 | * @return static |
|
| 2533 | * <p>Object whose $str has had spaces switched to tabs.</p> |
|
| 2534 | */ |
|
| 2535 | public function toTabs(int $tabLength = 4): self |
|
| 2536 | { |
|
| 2537 | if ($tabLength === 4) { |
|
| 2538 | $tab = ' '; |
|
| 2539 | } elseif ($tabLength === 2) { |
|
| 2540 | $tab = ' '; |
|
| 2541 | } else { |
|
| 2542 | $tab = \str_repeat(' ', $tabLength); |
|
| 2543 | } |
|
| 2544 | ||
| 2545 | return static::create( |
|
| 2546 | \str_replace($tab, "\t", $this->str), |
|
| 2547 | $this->encoding |
|
| 2548 | ); |
|
| 2549 | } |
|
| 2550 | ||
| 2551 | /** |
|
| 2552 | * Converts the first character of each word in the string to uppercase |
|