Git Product home page Git Product logo

colada's Introduction

Colada. Collections Framework for PHP Build Status

Goal

Convenient and safe way to work with collections.

Benefits

  • Rich maps (any type for keys).
  • Functional idioms:
    • immutable collections (safest and usable for most cases),
    • lazy operations โ€” don't skimp on it.
  • Optional values (to solve NPE problem).

Installation

Colada currently may be installed as submodule for your Git project:

git submodule add git://github.com/alexeyshockov/colada.git vendor/colada

or throught Composer:

{
    "require": {
        "alexeyshockov/colada": "dev-master"
    }
}

Usage

Follow project's wiki for usage information and examples.

Detailed API documentation (for current stable release).

Playing with interactive shell

Colada includes small wrapper for standard PHP interactive shell, which adds some useful functions to it.

Lets play with it!

$ ./shell.sh
// Call use_colada() function to benefit from all shortcuts ;)
Interactive shell

php > use_colada();
php > d(collection(-2, -1, 0, 1, 2));
$var0 = array(0 => -2, 1 => -1, 2 => 0, 3 => 1, 4 => 2)
php > // Call above are identical to: $var0->mapBy(function($x) { return $x + 1; });
php > d($var0->mapBy(x()->increment()));
$var1 = array(0 => -1, 1 => 0, 2 => 1, 3 => 2, 4 => 3)
php > d($var0->acceptBy(x()->isPositive()));
$var2 = array(0 => 0, 1 => 1, 2 => 2)
php > d($var0->rejectBy(x()->isPositive()));
$var3 = array(0 => -2, 1 => -1)

php > d($var0->groupsBy(function($x) { return ($x >= 0 ? 'positive' : 'negative'); }));
$var4 = array(
  0 =>
  array(
    0 => 'negative',
    1 =>
    array(
      0 => -2,
      1 => -1,
    ),
  ),
  1 =>
  array(
    0 => 'positive',
    1 =>
    array(
      0 => 0,
      1 => 1,
      2 => 2,
    ),
  ),
)

Roadmap

Detailed roadmap can be found in appropriate page.

colada's People

Contributors

alexeyshockov avatar pborreli avatar paulchubatyy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.