定制 lambdish/phunctional 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lambdish/phunctional

最新稳定版本:v2.1.0

Composer 安装命令:

composer require lambdish/phunctional

包简介

λ PHP functional library

README 文档

README

Phunctional, because functional programming matters.

Lambdish MIT License Version Monthly Downloads Travis Build Status

Lambdish's Phunctional is a little library that tries to bring to PHP some aspects of functional programing with util high order functions and functions for manage iterables.


About

Phunctional is heavily inspired by Clojure and some other PHP libraries like iter, compose and felpado.

The main principles that we have in mind developing this library are:

  • A collection can be any iterable PHP object, arrays or generators
  • Favor composition vs inheritance
  • Be lazy when you can
  • Avoid state, state is (usually) evil!
  • Simplicity over easiness
  • Break the above rules if it makes sense

All of this can be resumed with a word: Immutability.

Installation

To install it with composer:

composer require lambdish/phunctional

Simple usage

The first is to import every function you're going to use, for example:

use function Lambdish\phunctional\map;

And then you'll be able to use it:

map(
    function ($number) {
        return $number + 10;
    },
    [1, 2, 3, 4, 5]
);

// => [11, 12, 13, 14, 15]

And do something more complex like:

use function Lambdish\Phunctional\pipe;
use const Lambdish\Phunctional\{filter_null, reverse, first};

$lastNonNullableValue = pipe(filter_null, reverse, first);

$lastNonNullableValue(['first', null, 'other', 'last non nullable', null, null]);

// => "last non nullable"

Here we're using the provided constants, that acts like an alias for the functions full qualified namespace (and therefore, are callable).

Documentation

You can find the functions documentation here.

统计信息

  • 总下载量: 1.81M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 361
  • 点击次数: 1
  • 依赖项目数: 24
  • 推荐数: 1

GitHub 信息

  • Stars: 359
  • Watchers: 23
  • Forks: 37
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-09-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固