2017 © Pedro Peláez
 

library functional-array

A functional wrapper for arrays

image

park-brian/functional-array

A functional wrapper for arrays

  • Friday, September 29, 2017
  • by park-brian
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

LazyArray

Build Status Test Coverage, (*1)

Lazily-evaluated PHP arrays, (*2)

Requirements

  • php 5.6+

Getting Started

composer require park-brian/functional-array

Usage

<?php

use FunctionalArray\FunctionalArray as FnArray;

$sum = FnArray::create(range(1, 10))
  ->map     (function($value) { return $value * 2;  })
  ->filter  (function($value) { return $value > 10; })
  ->reduce  (function($acc = 0, $value) { return $acc + $value; });

echo $sum;

$fruitRatings = [
    'apples' => 70,
    'bananas' => 80,
    'cherries' => 90,
    'dragonfruit' => 100
];

$favoriteFruits = FnArray::create($fruitRatings)
  ->filter (function($value)        { return $value >= 80; })
  ->map    (function($value, $key)  { return "Rating for $key: $value"; })
  ->reduce (function($acc, $value)  { return " $acc \n $value"; })

echo $favoriteFruits;

The Versions

29/09 2017

dev-master

9999999-dev

A functional wrapper for arrays

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

21/09 2017

0.0.2

0.0.2.0

A functional wrapper for arrays

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

21/09 2017

0.0.1

0.0.1.0

A functional wrapper for arrays

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires