gregkos / greek-strings
A manipulation library for Greek strings
Fund package maintenance!
gregkos
Requires
- php: ^7.4|^8.0
- ext-mbstring: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.17
- phpunit/phpunit: ^9.5
- vimeo/psalm: ^4.3
This package is auto-updated.
Last update: 2024-10-20 00:58:18 UTC
README
A library to cover all your Greek string conversion needs.
Currently:
- Transliteration of Greek strings
- Uppercase / lowercase conversions
Planned:
- Open to feature requests! :)
Wishlist:
- Reverse transliteration
- Accent guesstimates
Installation
You can install the package via composer:
composer require gregkos/greek-strings
Usage
You can create a new string by calling the constructor:
$greek_string = new GregKos\GreekString('Καλημέρα!');
You can transliterate any greek letters in the string like so:
echo $greek_string->transliterate(); // Kalimera!
You can convert the string to UPPERCASE
...
echo $greek_string->toUpper(); // ΚΑΛΗΜΕΡΑ!
...or convert it to lowercase
echo $greek_string->toLower(); // καλημερα!
Keep in mind that conversions remove the accent unless you explicitly pass a parameter:
echo $greek_string->toUpper(false); // ΚΑΛΗΜΈΡΑ!
However, there is no efficient way to add an accent that was not there before:
$greek_string = new GregKos\GreekString('ΚΑΛΗΜΕΡΑ!'); echo $greek_string->toLower(); // καλημερα!
Method Reference
The following methods are available on any GreekString instance:
// Returns the string as is getString(): string // Set a new string for the instance // $str = a valid string setString(string $str): self // Return a transliterated version of the string transliterate(): string // Return an uppercase version of the string // $removeAccent = a bool to determine whether or not // to remove accent from the string (default: true) toUpper($removeAccent = true): string // Return an lowercase version of the string // $removeAccent = a bool to determine whether or not // to remove accent from the string (default: true) toLower($removeAccent = true): string
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Spatie for the package skeleton
- multipetros for the inspiration and parts of the code
- GregKos
- All Contributors
License
The MIT License (MIT). Please see License File for more information.