| @@ 2426-2440 (lines=15) @@ | ||
| 2423 | * @return static |
|
| 2424 | * <p>Object whose $str has had tabs switched to spaces.</p> |
|
| 2425 | */ |
|
| 2426 | public function toSpaces(int $tabLength = 4): self |
|
| 2427 | { |
|
| 2428 | if ($tabLength === 4) { |
|
| 2429 | $tab = ' '; |
|
| 2430 | } elseif ($tabLength === 2) { |
|
| 2431 | $tab = ' '; |
|
| 2432 | } else { |
|
| 2433 | $tab = \str_repeat(' ', $tabLength); |
|
| 2434 | } |
|
| 2435 | ||
| 2436 | return static::create( |
|
| 2437 | \str_replace("\t", $tab, $this->str), |
|
| 2438 | $this->encoding |
|
| 2439 | ); |
|
| 2440 | } |
|
| 2441 | ||
| 2442 | /** |
|
| 2443 | * Return Stringy object as string, but you can also use (string) for automatically casting the object into a |
|
| @@ 2463-2477 (lines=15) @@ | ||
| 2460 | * @return static |
|
| 2461 | * <p>Object whose $str has had spaces switched to tabs.</p> |
|
| 2462 | */ |
|
| 2463 | public function toTabs(int $tabLength = 4): self |
|
| 2464 | { |
|
| 2465 | if ($tabLength === 4) { |
|
| 2466 | $tab = ' '; |
|
| 2467 | } elseif ($tabLength === 2) { |
|
| 2468 | $tab = ' '; |
|
| 2469 | } else { |
|
| 2470 | $tab = \str_repeat(' ', $tabLength); |
|
| 2471 | } |
|
| 2472 | ||
| 2473 | return static::create( |
|
| 2474 | \str_replace($tab, "\t", $this->str), |
|
| 2475 | $this->encoding |
|
| 2476 | ); |
|
| 2477 | } |
|
| 2478 | ||
| 2479 | /** |
|
| 2480 | * Converts the first character of each word in the string to uppercase |
|