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