2017 © Pedro Peláez
 

library rich-types

Yet another rich types library.

image

urmaul/rich-types

Yet another rich types library.

  • Tuesday, February 6, 2018
  • by urmaul
  • Repository
  • 1 Watchers
  • 0 Stars
  • 300 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 16 Versions
  • 0 % Grown

The README.md

rich-types

Yet another rich types library. Designed to use fluent interaces with base PHP types., (*1)

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

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

php composer.phar require urmaul/rich-types '0.3.*', (*4)

Build Status, (*5)

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()., (*6)

  • 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., (*7)

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

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

The Versions

06/02 2018

dev-master

9999999-dev https://github.com/urmaul/rich-types

Yet another rich types library.

  Sources   Download

Apache-2.0 Apache 2.0

The Requires

 

The Development Requires

types collections

06/02 2018

0.3.4

0.3.4.0 https://github.com/urmaul/rich-types

Yet another rich types library.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

types collections

17/06 2016

0.3.3

0.3.3.0 https://github.com/urmaul/rich-types

Yet another rich types library.

  Sources   Download

Apache 2.0

The Requires

 

The Development Requires

types collections

19/05 2016

0.3.2

0.3.2.0 https://github.com/urmaul/rich-types

Yet another rich types library.

  Sources   Download

Apache 2.0

The Requires

 

The Development Requires

types collections

14/06 2015

v0.3.1

0.3.1.0 https://github.com/urmaul/rich-types

Yet another rich types library.

  Sources   Download

Apache 2.0

The Requires

 

The Development Requires

types collections

22/04 2015

v0.3.0

0.3.0.0 https://github.com/urmaul/rich-types

Yet another rich types library.

  Sources   Download

Apache 2.0

The Requires

 

The Development Requires

types collections

21/04 2015

v0.2.8

0.2.8.0 https://github.com/urmaul/rich-types

Yet another rich types library.

  Sources   Download

Apache 2.0

The Requires

 

The Development Requires

types collections

06/03 2015

v0.2.7

0.2.7.0 https://github.com/urmaul/rich-types

Yet another rich types library.

  Sources   Download

Apache 2.0

The Requires

  • php >=5.4

 

The Development Requires

types collections

06/03 2015

v0.2.6

0.2.6.0 https://github.com/urmaul/rich-types

Yet another rich types library.

  Sources   Download

Apache 2.0

The Requires

  • php >=5.4

 

The Development Requires

types collections

06/03 2015

v0.2.5

0.2.5.0 https://github.com/urmaul/rich-types

Yet another rich types library.

  Sources   Download

Apache 2.0

The Requires

  • php >=5.4

 

The Development Requires

types collections

24/02 2015

v0.2.4

0.2.4.0 https://github.com/urmaul/rich-types

Yet another rich types library.

  Sources   Download

Apache 2.0

The Requires

  • php >=5.4

 

The Development Requires

types collections

22/01 2015

v0.2.3

0.2.3.0 https://github.com/urmaul/rich-types

Yet another rich types library.

  Sources   Download

Apache 2.0

The Requires

  • php >=5.4

 

The Development Requires

types collections

19/01 2015

v0.2.2

0.2.2.0 https://github.com/urmaul/rich-types

Yet another rich types library.

  Sources   Download

Apache 2.0

The Requires

  • php >=5.4

 

The Development Requires

types collections

12/01 2015

v0.2.1

0.2.1.0 https://github.com/urmaul/rich-types

Yet another rich types library.

  Sources   Download

Apache 2.0

The Requires

  • php >=5.4

 

The Development Requires

types collections

09/01 2015

v0.2.0

0.2.0.0 https://github.com/urmaul/rich-types

Yet another rich types library.

  Sources   Download

Apache 2.0

The Requires

  • php >=5.4

 

The Development Requires

types collections

09/01 2015

v0.1

0.1.0.0 https://github.com/urmaul/rich-types

Yet another rich types library.

  Sources   Download

Apache 2.0

The Requires

  • php >=5.4

 

types collections