2017 © Pedro Peláez
 

library plazy

Lazy data access library

image

mpstyle/plazy

Lazy data access library

  • Saturday, August 6, 2016
  • by MpStyle
  • Repository
  • 0 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

plazy

Another functional library for PHP 7., (*1)

Quickstart

To use plazy in your projects install composer and add to your composer.json file:, (*2)

"require": {
    "mpstyle/plazy": "0.2.3"
}

Or run:, (*3)

composer require "mpstyle/plazy"

Sequence

The sequence class allows you to build up a computation out of smaller operations. It's similar to Java 8 Streams, (*4)

Now we can try some of the following:, (*5)

Sequence::sequence(1, 2, 3, 4)->filter(even); // lazily returns 2,4
Sequence::sequence(1, 2)->map(toString); // lazily returns "1", "2"
Sequence::sequence(1, 2, 3)->take(2); // lazily returns 1,2
Sequence::sequence(1, 2, 3)->drop(2); // lazily returns 3
Sequence::sequence(1, 2, 3)->tail(); // lazily returns 2,3
Sequence::sequence(1, 2, 3)->head(); // eagerly returns 1
Sequence::sequence(1, 3, 5)->find(even); // eagerly returns none()
Sequence::sequence(1, 2, 3)->contains(2); // eagerly returns true
Sequence::sequence(1, 2, 3)->toString(":"); // eagerly returns "1:2:3"

Option

Optional value - type-safe null, (*6)

Functions

plazy provides some interfaces for functional uages, such as:, (*7)

  • F: to transform an object to another one.
  • Predicate: to filter/select/match an object.
  • Validator: to validate an object.

Developers

To run unit test, run in the root of the plazy project:, (*8)

composer phptest

The Versions

06/08 2016

dev-master

9999999-dev

Lazy data access library

  Sources   Download

LGPL v3

The Development Requires