dotink/flourish-collection 问题修复 & 功能扩展

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

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

dotink/flourish-collection

最新稳定版本:1.1.6

Composer 安装命令:

composer require dotink/flourish-collection

包简介

A rudimentary collection class

关键字:

README 文档

README

Build Status

This is a super simple collection class which is designed to be extended. It is mostely useful where you need selective collection querying or default values with ease.

Basic Usage

$collection = new Dotink\Flourish\Collection([
	'a' => 'apple',
	'b' => 'banana',
	'c' => 'carrot'
]);

Get a Value

$collection->get('a'); // returns 'apple'

Get a Value + Default

$collection->get('d', 'date'); // returns 'date'

Get Multiple Values

$collection->get(['a', 'c']); // returns ['a' => 'apple', 'c' => 'carrot']

Set a Value

$collection->set('d', 'date');

Set Multiple Values

$collection->set([
	'e' => 'eggplant',
	'f' => 'fig'
]);

Iterate Over the Collection

foreach ($collection as $letter => $fruit_or_vegetable) {
	echo sprintf(
		'The letter "%s" is for "%s"',
		$letter,
		$fruit_or_vegetable
	);
}

Compound Keys

It is possible to use compound keys to access data (both getting and setting) in nested arrays.

Set Nested Data

$collection->set('foo.bar', 'foobar'); // $collection->get('foo') returns ['bar' => 'foobar']

Get Nested Data

$collection->get('foo.bar'); // return 'foobar'

统计信息

  • 总下载量: 905
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: AGPL-3.0
  • 更新时间: 2015-06-06