| @@ 2021-2031 (lines=11) @@ | ||
| 2018 | * |
|
| 2019 | * @return static |
|
| 2020 | */ |
|
| 2021 | public function kebabCase(): self |
|
| 2022 | { |
|
| 2023 | $words = \array_map( |
|
| 2024 | static function (self $word) { |
|
| 2025 | return $word->toLowerCase(); |
|
| 2026 | }, |
|
| 2027 | $this->words('', true) |
|
| 2028 | ); |
|
| 2029 | ||
| 2030 | return new static(\implode('-', $words), $this->encoding); |
|
| 2031 | } |
|
| 2032 | ||
| 2033 | /** |
|
| 2034 | * Returns the last $n characters of the string. |
|
| @@ 3156-3166 (lines=11) @@ | ||
| 3153 | * |
|
| 3154 | * @return static |
|
| 3155 | */ |
|
| 3156 | public function snakeCase(): self |
|
| 3157 | { |
|
| 3158 | $words = \array_map( |
|
| 3159 | static function (self $word) { |
|
| 3160 | return $word->toLowerCase(); |
|
| 3161 | }, |
|
| 3162 | $this->words('', true) |
|
| 3163 | ); |
|
| 3164 | ||
| 3165 | return new static(\implode('_', $words), $this->encoding); |
|
| 3166 | } |
|
| 3167 | ||
| 3168 | /** |
|
| 3169 | * Convert a string to e.g.: "snake_case" |
|