| @@ 2803-2817 (lines=15) @@ | ||
| 2800 | * @return static |
|
| 2801 | * <p>Object whose $str has had tabs switched to spaces.</p> |
|
| 2802 | */ |
|
| 2803 | public function toSpaces(int $tabLength = 4): self |
|
| 2804 | { |
|
| 2805 | if ($tabLength === 4) { |
|
| 2806 | $tab = ' '; |
|
| 2807 | } elseif ($tabLength === 2) { |
|
| 2808 | $tab = ' '; |
|
| 2809 | } else { |
|
| 2810 | $tab = \str_repeat(' ', $tabLength); |
|
| 2811 | } |
|
| 2812 | ||
| 2813 | return static::create( |
|
| 2814 | \str_replace("\t", $tab, $this->str), |
|
| 2815 | $this->encoding |
|
| 2816 | ); |
|
| 2817 | } |
|
| 2818 | ||
| 2819 | /** |
|
| 2820 | * Return Stringy object as string, but you can also use (string) for automatically casting the object into a |
|
| @@ 2844-2858 (lines=15) @@ | ||
| 2841 | * @return static |
|
| 2842 | * <p>Object whose $str has had spaces switched to tabs.</p> |
|
| 2843 | */ |
|
| 2844 | public function toTabs(int $tabLength = 4): self |
|
| 2845 | { |
|
| 2846 | if ($tabLength === 4) { |
|
| 2847 | $tab = ' '; |
|
| 2848 | } elseif ($tabLength === 2) { |
|
| 2849 | $tab = ' '; |
|
| 2850 | } else { |
|
| 2851 | $tab = \str_repeat(' ', $tabLength); |
|
| 2852 | } |
|
| 2853 | ||
| 2854 | return static::create( |
|
| 2855 | \str_replace($tab, "\t", $this->str), |
|
| 2856 | $this->encoding |
|
| 2857 | ); |
|
| 2858 | } |
|
| 2859 | ||
| 2860 | /** |
|
| 2861 | * Converts the first character of each word in the string to uppercase |
|