pixel418/ubiq

用于可读性处理字符串、数组与对象的功能

v0.5.0 2014-01-30 21:09 UTC

README

用于可读性处理字符串、数组与对象的功能。

  1. 开始编码
    1.1 简单
    1.2 可读性
    1.3 标准化
  2. 文档
    2.1 字符串操作
    2.2 数组操作
    2.3 对象操作
  3. 如何安装
  4. 如何贡献
  5. 作者 & 社区

开始编码

简单

使用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' );

↑ 顶部

如何贡献

  1. Fork Ubiq仓库
  2. 为每个功能或改进创建一个新的分支
  3. 从每个功能分支向develop分支发送pull request

如果你对pull request不太了解,可以阅读GitHub文章

所有pull request都必须遵循PSR1标准,并附带通过phpunit测试。

↑ 顶部

作者 & 社区

Ubiq遵循MIT许可证
Thomas ZILLIOX创建和维护。

↑ 顶部