Giter VIP home page Giter VIP logo

colada's Introduction

Colada

Latest Stable Version Build Status Test Coverage

Goal

Convenient and safe way to work with collections.

...And it's been (more or less) solved by some other libraries, like nikic/iter, doctrine/collections or even php-ds/php-ds. That's why the current version of the library contains just a few helpers for that libraries, to conveniently integrate them together.

Installation

composer require alexeyshockov/colada:~3.0

Usage

The library's functions are split by namespaces, one namespace = specific function a dependency (in most cases).

\Colada\ds\{group_by}

Helpers from this namespace require php-ds/php-ds to be available.

group_by() function prodices a two dimension array (\ArrayObject or \Ds\Map, depends on the group key type), from an iterable based on a group function.

TODO

\Colada\GuzzleHttp\{coroutine_invoke, coroutine, time_sleep}

\Colada\React\{coroutine_invoke, coroutine}

Helpers from this namespace require guzzlehttp/promises or react/promise to be available.

This is the same concept applied to two most popular libs with async capabilities. If you are familiar with async/await in C# or node.js or coroutines in Go, this should be simple. Take a look at the script, written in callback-style and in coroutine-style:

TODO
TODO

\Colada\iter\opt\{get, head, last, find_one}

Helpers from this namespace require phpoption/phpoption to be available.

\Colada\iter\{to_kv_pairs, each_n_and_last, uasort, uksort}

Simple helpers for general iterable types.

uasort() and uksort() are basically equivalents for the internal ones, but work for arbitrary iterable type.

Contributing

Running Tests

To run all the tests, install the vendors (with Composer) and execute:

vendor/bin/phpunit --testdox

Public API

All classes or functions that are intended to be used by a user should be marked with @api PHPDoc tag. Anything without this mark are internal and should not be used by the end user (no guarantees that the interface will stay the same between versions).

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.