| @@ 2020-2030 (lines=11) @@ | ||
| 2017 | * |
|
| 2018 | * @return static |
|
| 2019 | */ |
|
| 2020 | public function kebabCase(): self |
|
| 2021 | { |
|
| 2022 | $words = \array_map( |
|
| 2023 | static function (self $word) { |
|
| 2024 | return $word->toLowerCase(); |
|
| 2025 | }, |
|
| 2026 | $this->words('', true) |
|
| 2027 | ); |
|
| 2028 | ||
| 2029 | return new static(\implode('-', $words), $this->encoding); |
|
| 2030 | } |
|
| 2031 | ||
| 2032 | /** |
|
| 2033 | * Returns the last $n characters of the string. |
|
| @@ 3145-3155 (lines=11) @@ | ||
| 3142 | * |
|
| 3143 | * @return static |
|
| 3144 | */ |
|
| 3145 | public function snakeCase(): self |
|
| 3146 | { |
|
| 3147 | $words = \array_map( |
|
| 3148 | static function (self $word) { |
|
| 3149 | return $word->toLowerCase(); |
|
| 3150 | }, |
|
| 3151 | $this->words('', true) |
|
| 3152 | ); |
|
| 3153 | ||
| 3154 | return new static(\implode('_', $words), $this->encoding); |
|
| 3155 | } |
|
| 3156 | ||
| 3157 | /** |
|
| 3158 | * Convert a string to e.g.: "snake_case" |
|