ogoudat / core
一组基本工具,使PHP处理更简单。
dev-master
2017-10-22 14:09 UTC
Requires
- php: >=7.0
- ext-iconv: *
- ext-intl: *
- ext-mbstring: *
- ext-pcre: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.7
- phpunit/phpunit: ^6.4
This package is not auto-updated.
Last update: 2024-09-29 05:01:31 UTC
README
Ogöudat的PHP核心库的主要目标是提供一套经过良好测试的坚实基础,以便在PHP中进行字符串操作和语言处理。
请注意,该项目处于早期阶段,代码尚未准备好用于生产使用。
安装
composer require ogoudat/core
字符串
在PHP中处理Unicode字符串可能会很困难且容易出错。`Strang`类试图通过面向对象接口隐藏一些这种复杂性。
字符
通常,当使用标准字符串函数如`strlen`时,长度表示字节数。当使用`Strang`时,长度表示字符数。
<?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
您可以将每个字符作为`Character`对象数组的元素来获取,它有一套自己的方法。
<?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; }
编码风格
本项目试图遵循PSR-2中描述的编码风格。PSR-2。在此部分中记录PSR-2未涵盖的内容。
如果您想使用PHP编码标准修复工具,请将`.php_cs.dist`配置文件复制到`.php_cs`,然后从项目根目录运行`php-cs-fixer fix`。
许可证
此库使用BSD许可证。有关详细信息,请参阅`LICENSE.md`文件。