sclable / php-toolbox
此软件包已被废弃,不再维护。没有建议的替代软件包。
一套小而实用的助手,你肯定不想在你的项目中错过。
0.0.4.2
2016-03-02 12:42 UTC
Requires (Dev)
- evert/phpdoc-md: ^0.1.1
- phing/phing: ^2.13
- phpdocumentor/phpdocumentor: ^2.8
- phpunit/phpunit: ^4.8
- sclable/coding-standards: ^0.1.0.2
This package is not auto-updated.
Last update: 2016-06-29 12:30:00 UTC
README
一套小而实用的助手,你肯定不想在你的项目中错过。
用法
使用BOB安装
要在此Sclable业务应用程序开发平台项目中使用此库,请要求BOB(我们的构建器)添加此软件包
# add dependency
bob package-add sclable-php-toolbox
# download & install
bob build
使用Composer安装
如果您想使用Composer将此库包含到项目中,只需运行
composer require "sclable/php-toolbox"
工具
范围
从自定义基本范围派生出任意长度的范围。
API文档范围对象的API文档位于此处。
示例重新索引数组,从A到Z的大写字母
$values = range(1,32); // integers from 1 to 32 $range = new Range(); $range->upper(); $result = $range->combine($values); var_dump($result); /* prints array(32) { 'A' => int(1) 'B' => int(2) [...] 'AE' => int(31) 'AF' => int(32) } */
ArrayColumn
API文档ArrayColumn对象的API文档位于此处。
示例从多维数组中提取数组元素的键和值
$data = [ ['id' => 1, 'column' => 'a'], ['id' => 2, 'column' => 'b'], ['id' => 3, 'column' => 'c'], ]; $result = ArrayColumn::create() ->index('id') ->data('column') ->from($data) ->get(); var_dump($result); // array(3) { // [1] => string(1) "a" // [2] => string(1) "b" // [3] => string(1) "c" // }
ObjectColumn
API文档ObjectColumn对象的API文档位于此处。
示例从对象属性中提取数组元素的键和值
$data = [ (object) ['id' => 1, 'column' => 'a'], (object) ['id' => 2, 'column' => 'b'], (object) ['id' => 3, 'column' => 'c'], ]; $result = ObjectColumn::create() ->from($data) // the list of objects ->assignById() // a shortcut for ->assignBy('id') ->with('column') // the object property containing the data ->get(); var_dump($result); // array(3) { // [1] => string(1) "a" // [2] => string(1) "b" // [3] => string(1) "c" // }
Initials
API文档Initials对象的API文档位于此处。
示例获取任何文本的首字母缩写
$initials = new Initials( 'Sclable Business Application Development Platform' ); echo $initials; // echo 'SB' echo $initials->setLength(5); // echo 'SBADP'
$initials = new Initials( 'sclable-domain-designer' ); echo $initials->setLength(3)->setCase(Initials::CASE_SENSITIVE)->addSeparator('-'); // echo 'sdd'
许可证
有关许可证和版权,请参阅LICENSE文件