pixel418 / ubiq
用于可读性处理字符串、数组与对象的功能
v0.5.0
2014-01-30 21:09 UTC
Requires
- php: >=5.3.0
README
用于可读性处理字符串、数组与对象的功能。
开始编码
简单
使用Ubiq,你的处理方式简单。
$string = 'example.com/my/path'; \UString::substrBefore( $string, '/' ); // Returns 'example.com' // Instead of usual implementation: substr( $string, 0, strpos( $string, '/' ) );
可读性
使用Ubiq,即使你的复杂处理也能保持可读性。
$string = 'example.com/my/path'; \UString::substrBefore( $string, '/' ); // Returns 'example.com'
\UString::substrBefore( $string, [ '/', '.' ] ); // Returns 'example'
\UString::substrBeforeLast( $string, [ '/', '.' ] ); // Returns 'example.com/my'
标准化
Ubiq具有一致和标准化的API。
$string = 'my/path'; // Without prefix, the method return the result of the treatment \UString::startWith( $string, '/' ); // Returns '/my/path'
$string = 'my/path'; // With 'is' prefix, the method return the result of the test \UString::isStartWith( $string, '/' ); // Returns FALSE
$string = 'my/path'; // With 'do' prefix, the method treat by reference \UString::doStartWith( $string, '/' ); // $string value is now '/my/path'
如何安装
如果你没有Composer,你必须安装它。
在你的仓库根目录下添加或完善composer.json文件,如下所示
{ "require": { "pixel418/ubiq": "0.4.*" } }
现在可以通过Composer下载Ubiq。
要使用它,你只需加载composer自动加载器
require_once( './vendor/autoload.php' );
如何贡献
- Fork Ubiq仓库
- 为每个功能或改进创建一个新的分支
- 从每个功能分支向develop分支发送pull request
如果你对pull request不太了解,可以阅读GitHub文章。
所有pull request都必须遵循PSR1标准,并附带通过phpunit测试。
作者 & 社区
Ubiq遵循MIT许可证。
由Thomas ZILLIOX创建和维护。