| @@ 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. |
|
| @@ 3154-3164 (lines=11) @@ | ||
| 3151 | * |
|
| 3152 | * @return static |
|
| 3153 | */ |
|
| 3154 | public function snakeCase(): self |
|
| 3155 | { |
|
| 3156 | $words = \array_map( |
|
| 3157 | static function (self $word) { |
|
| 3158 | return $word->toLowerCase(); |
|
| 3159 | }, |
|
| 3160 | $this->words('', true) |
|
| 3161 | ); |
|
| 3162 | ||
| 3163 | return new static(\implode('_', $words), $this->encoding); |
|
| 3164 | } |
|
| 3165 | ||
| 3166 | /** |
|
| 3167 | * Convert a string to e.g.: "snake_case" |
|