定制 urmaul/rich-types 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

urmaul/rich-types

最新稳定版本:0.3.4

Composer 安装命令:

composer require urmaul/rich-types

包简介

Yet another rich types library.

README 文档

README

Yet another rich types library. Designed to use fluent interaces with base PHP types.

No Not enough comments, no tests, no release planned. Use it only if you are me brave enough.

While major version is 0 minor version change means backwards incompatible changes. So you should install it with composer like this:

php composer.phar require urmaul/rich-types '0.3.*'

Build Status

Example

use rich\collections\Strings;

$words = Strings::split(' ', $text)->lower()->unique()->values();

Supported types

Collections

Variables

Base collection class. Can be passed to foreach and count().

  • static from($array) - creates new collection instance.
  • map($callback) - performs array_map to each item in collection.
  • indexBy($callback) - maps values to keys using callback.
  • mapKeys(array $replaces, $strict = true) - replaces collection keys using map array..
  • filter($callback = null) - performs array_filter to each item in collection.
  • diff($array) - Removes from collection all items that are present in $array using array_diff.
  • unique() - performs array_unique to collection.
  • merge($array) - merges another array to collection.
  • find($callback) - finds an item by callback function. Returns it's value.
  • reduce($callback, $initial = null) - performs array_reduce to collection. Returns resulting value.
  • count() - returns items count.
  • value() - returns collection data preserving keys.
  • values() - returns collection items as array indexed numerically.
  • asVariables() - converts collection to Variables. Can be used to clone collection.
  • asNumbers() - converts collection to Numbers. Can be used to clone collection.
  • asStrings() - converts collection to Strings. Can be used to clone collection.
  • asObjects() - converts collection to Objects. Can be used to clone collection.

Strings

  • static split($delimiter, $string) - creates new collection instance by splitting text like explode does.
  • static splitList($string) - creates new collection instance by splitting text wtih comma-separated values.
  • lower() - makes every string in collection lowercase.
  • trim() - performs trim to each item in collection.
  • replace($search, $replace) - performs str_replace to each item in collection.

Numbers

  • sum() - returns collection items sum.

Objects

  • property($property) - cleates new collection with items picked from objects property.

Arrays

  • column($columnKey, $indexKey = null) - returns the values from a single column of the array, identified by the column_key. Optionally, you may provide an index_key to index the values in the returned array by the values from the index_key column in the input array.

    Performs array_column to collection. If php version is lower than 5.5, ramsey/array_column is used.

  • indexByColumn($columnKey) - uses the values from a single column of the array as collection keys.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2015-01-09