|
| 1 | +<!-- |
| 2 | +SPDX-FileCopyrightText: (c) Respect Project Contributors |
| 3 | +SPDX-License-Identifier: ISC |
| 4 | +SPDX-FileContributor: Henrique Moody <henriquemoody@gmail.com> |
| 5 | +--> |
| 6 | + |
| 7 | +# LowercaseFormatter |
| 8 | + |
| 9 | +The `LowercaseFormatter` converts strings to lowercase with proper UTF-8 character support for international text. |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +### Basic Usage |
| 14 | + |
| 15 | +```php |
| 16 | +use Respect\StringFormatter\LowercaseFormatter; |
| 17 | + |
| 18 | +$formatter = new LowercaseFormatter(); |
| 19 | + |
| 20 | +echo $formatter->format('HELLO WORLD'); |
| 21 | +// Outputs: "hello world" |
| 22 | +``` |
| 23 | + |
| 24 | +### Unicode Characters |
| 25 | + |
| 26 | +```php |
| 27 | +use Respect\StringFormatter\LowercaseFormatter; |
| 28 | + |
| 29 | +$formatter = new LowercaseFormatter(); |
| 30 | + |
| 31 | +echo $formatter->format('CAFÉ FRANÇAIS'); |
| 32 | +// Outputs: "café français" |
| 33 | + |
| 34 | +echo $formatter->format('コンニチハ'); |
| 35 | +// Outputs: "コンニチハ" |
| 36 | +``` |
| 37 | + |
| 38 | +### Mixed Content |
| 39 | + |
| 40 | +```php |
| 41 | +use Respect\StringFormatter\LowercaseFormatter; |
| 42 | + |
| 43 | +$formatter = new LowercaseFormatter(); |
| 44 | + |
| 45 | +echo $formatter->format('HELLO WORLD 😊'); |
| 46 | +// Outputs: "hello world 😊" |
| 47 | +``` |
| 48 | + |
| 49 | +## API |
| 50 | + |
| 51 | +### `LowercaseFormatter::__construct` |
| 52 | + |
| 53 | +- `__construct()` |
| 54 | + |
| 55 | +Creates a new lowercase formatter instance. |
| 56 | + |
| 57 | +### `format` |
| 58 | + |
| 59 | +- `format(string $input): string` |
| 60 | + |
| 61 | +Converts the input string to lowercase using UTF-8 aware conversion. |
| 62 | + |
| 63 | +**Parameters:** |
| 64 | + |
| 65 | +- `$input`: The string to convert to lowercase |
| 66 | + |
| 67 | +**Returns:** The lowercase string |
| 68 | + |
| 69 | +## Examples |
| 70 | + |
| 71 | +| Input | Output | Description | |
| 72 | +| ------------ | ------------ | ----------------------------- | |
| 73 | +| `HELLO` | `hello` | Simple ASCII text | |
| 74 | +| `CAFÉ` | `café` | Latin characters with accents | |
| 75 | +| `ПРИВЕТ` | `привет` | Cyrillic text | |
| 76 | +| `コンニチハ` | `コンニチハ` | Japanese text | |
| 77 | +| `HELLO 😊` | `hello 😊` | Text with emoji | |
| 78 | +| `ÉÎÔÛ` | `éîôû` | Multiple accented characters | |
| 79 | + |
| 80 | +## Notes |
| 81 | + |
| 82 | +- Uses `mb_strtolower()` for proper Unicode handling |
| 83 | +- Preserves accent marks and diacritical marks |
| 84 | +- Works with all Unicode scripts (Latin, Cyrillic, Greek, CJK, etc.) |
| 85 | +- Emoji and special symbols are preserved unchanged |
| 86 | +- Combining diacritics are properly handled |
| 87 | +- Numbers and special characters remain unchanged |
| 88 | +- Empty strings return empty strings |
0 commit comments