Skip to content

A manipulation library for Greek strings

License

Notifications You must be signed in to change notification settings

gregkos/greek-strings

Repository files navigation

A manipulation library for Greek strings

Latest Version on Packagist GitHub Tests Action Status Total Downloads

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

License

The MIT License (MIT). Please see License File for more information.

About

A manipulation library for Greek strings

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Languages