Ogöudat's core PHP library
The main goal of Ogöudat's core PHP library is to provide a solid well-tested foundation when working with string manipulation and language processing in PHP., (*1)
Please note that this project is in an early stage and the code is not ready for production use yet., (*2)
Installation
composer require ogoudat/core
Strings
Working with Unicode strings in PHP can be difficult and error prone. The Strang class is an attempt to hide some of that complexity behind an object-oriented interface., (*3)
Characters
Typically, when working with standard string functions like strlen, length means the number of bytes. When using a Strang the length is the number of characters., (*4)
<?php
use Ogoudat\Core\Strang;
// let us assume that the code is UTF-8 encoded
$name = new Strang('Ogöudat');
echo $name->length() . PHP_EOL; // will print 7
echo $name->byteCount() . PHP_EOL; // will print 8
You can get each character as an array of Character objects which has its own set of methods., (*5)
<?php
use Ogoudat\Core\Strang;
// let us assume that the code is UTF-8 encoded
$strang = new Strang('αÎČÎł');
// Will take each character, make it upper case, and print it along with the
// code point for that character.
foreach ($strang->characters() as $character) {
$c = $character->toUpperCase();
echo $c . ': ' . $c->codePoint() . PHP_EOL;
}
Coding Style
This project tries to follow the coding style described in PSR-2. Use this section to document things that PSR-2 doesn't cover., (*6)
If you would like to use the PHP Coding Standards Fixer copy the .php_cs.dist configuration file to .php_cs and run php-cs-fixer fix from the project root directory., (*7)
License
This library is licensed under the BSD license. See the LICENSE.md file for details., (*8)