sclable/php-toolbox 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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.

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

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 Documentation

The API Documentation of the Range object is located here.

Example

Re-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 Documentation

The API Documentation of the ArrayColumn object is located here.

Example

Extract 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 Documentation

The API Documentation of the ObjectColumn object is located here.

Example

Extract 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 Documentation

The API Documentation of the Initials object is located here.

Example

Get 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

GitHub 信息

  • Stars: 2
  • Watchers: 5
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-08