| @@ 2439-2453 (lines=15) @@ | ||
| 2436 | * @return static |
|
| 2437 | * <p>Object whose $str has had tabs switched to spaces.</p> |
|
| 2438 | */ |
|
| 2439 | public function toSpaces(int $tabLength = 4): self |
|
| 2440 | { |
|
| 2441 | if ($tabLength === 4) { |
|
| 2442 | $tab = ' '; |
|
| 2443 | } elseif ($tabLength === 2) { |
|
| 2444 | $tab = ' '; |
|
| 2445 | } else { |
|
| 2446 | $tab = \str_repeat(' ', $tabLength); |
|
| 2447 | } |
|
| 2448 | ||
| 2449 | return static::create( |
|
| 2450 | \str_replace("\t", $tab, $this->str), |
|
| 2451 | $this->encoding |
|
| 2452 | ); |
|
| 2453 | } |
|
| 2454 | ||
| 2455 | /** |
|
| 2456 | * Return Stringy object as string, but you can also use (string) for automatically casting the object into a |
|
| @@ 2476-2490 (lines=15) @@ | ||
| 2473 | * @return static |
|
| 2474 | * <p>Object whose $str has had spaces switched to tabs.</p> |
|
| 2475 | */ |
|
| 2476 | public function toTabs(int $tabLength = 4): self |
|
| 2477 | { |
|
| 2478 | if ($tabLength === 4) { |
|
| 2479 | $tab = ' '; |
|
| 2480 | } elseif ($tabLength === 2) { |
|
| 2481 | $tab = ' '; |
|
| 2482 | } else { |
|
| 2483 | $tab = \str_repeat(' ', $tabLength); |
|
| 2484 | } |
|
| 2485 | ||
| 2486 | return static::create( |
|
| 2487 | \str_replace($tab, "\t", $this->str), |
|
| 2488 | $this->encoding |
|
| 2489 | ); |
|
| 2490 | } |
|
| 2491 | ||
| 2492 | /** |
|
| 2493 | * Converts the first character of each word in the string to uppercase |
|