sclable/php-toolbox
最新稳定版本:0.0.4.2
Composer 安装命令:
composer require sclable/php-toolbox
包简介
A set of small and useful helpers you should not miss in your project.
README 文档
README
A set of small and useful helpers you should not miss in your project.
Usage
Installation with BOB
To use this library in your Sclable Business Application Development Platform project, ask BOB (BOB Our Builder) to add the package:
# add dependency
bob package-add sclable-php-toolbox
# download & install
bob build
Installation with Composer
If you'd like to include this library in your project with composer, simply run:
composer require "sclable/php-toolbox"
Tools
Range
Create ranges of an arbitrary length derived from a custom base range.
API DocumentationThe API Documentation of the Range object is located here.
ExampleRe-index your array with upper case letters from 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 DocumentationThe API Documentation of the ArrayColumn object is located here.
ExampleExtract the key and the value for the array element from a multidimensional array:
$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 DocumentationThe API Documentation of the ObjectColumn object is located here.
ExampleExtract the key and the value for the array element from an object property:
$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 DocumentationThe API Documentation of the Initials object is located here.
ExampleGet the initials for any text:
$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
For the license and copyright see the LICENSE file
统计信息
- 总下载量: 253
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-08