PHPackages                             baethon/phln - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. baethon/phln

ActiveLibrary

baethon/phln
============

Set of small utility functions. Inspired by Ramda.

2.2.0(6y ago)187522[4 issues](https://github.com/baethon/phln/issues)MITPHPPHP &gt;=7.4CI failing

Since Jul 7Pushed 5y ago2 watchersCompare

[ Source](https://github.com/baethon/phln)[ Packagist](https://packagist.org/packages/baethon/phln)[ RSS](/packages/baethon-phln/feed)WikiDiscussions 3.x Synced 1mo ago

READMEChangelog (3)Dependencies (8)Versions (8)Used By (0)

[![Build Status](https://camo.githubusercontent.com/61cdaa1615b160f09e40020533a5e1034857c82939d9b6c1a76a94050605bb34/68747470733a2f2f7472617669732d63692e6f72672f62616574686f6e2f70686c6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/baethon/phln) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/2d50a2167f57b97a6c707b64b4375dce89ed1f4825f8296f98528d7955e02342/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62616574686f6e2f70686c6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/baethon/phln/?branch=master)

---

baethon/phln
============

[](#baethonphln)

Set of small utility functions.

Heavily inspired by [Ramda.js](http://ramdajs.com/), adapted for PHP needs.

Installation
------------

[](#installation)

```
composer require baethon/phln
```

Example usage
-------------

[](#example-usage)

```
use Baethon\Phln\Phln as P;

$aboveMinPoints = P::compose(P::lte(50), P::prop('score'));
$onlyPhp = P::pathEq('language.name', 'PHP');

$topScores = collect($users)
    ->filter(P::both($aboveMinPoints, $onlyPhp));
```

*Note*: in the docs `P` will be used as an alias to `Baethon\Phln\Phln`.

### Currying

[](#currying)

`Phln` methods are loosely curried. A `N-ary` method will return a function until all arguments are provided.

```
$foo = P::curryN(2, function ($left, $right) {
    return $left + $right;
});

$foo(1); // returns instance of \Closure
$foo(1, 2); // 3
$foo(1)(2); // 3
```

### Partial application

[](#partial-application)

Partial application is possible with combination of `P::partial()` and `P::__` const. Partial returns a function which accepts arguments which should "fill" gap of missing arguments for callable.

```
$foos = [1, 2, 3];
$mapFoos = P::partial('\\array_map', [P::__, $foos]);
$mapFoos(function ($f) {
    return $f + 100;
}); // [100, 200, 300]
```

### Function composition

[](#function-composition)

For function composition `phln` provides `pipe()` and `compose()` functions.

```
$allFoos = P::pipe(
    P::filter(P::lte(5)),
    P::map(P::always('foo'))
);

$firstFoo = P::compose(P::head(), $allFoos);

$allFoos([4, 5, 6]); // ['foo', 'foo']
$firstFoo([4, 5, 6]); // 'foo'
```

### Using methods as references

[](#using-methods-as-references)

Some of `phln` methods accept `callable` as an argument.

To pass another macro as a *reference* call it without any arguments.

```
$collection = [1, 2, 3, 4];
P::reduce(P::sum(), $collection); // 10
```

Also, you can use `P::raw()` method wich returns uncurried macro, or pointer to `Phln` method.

### Extending

[](#extending)

`Baethon\Phln\Phln` is *macroable*. This means that it can be extened using `macro()` method:

```
P::macro('foo', function () {
    return 'foo';
});

P::foo(); // 'foo'
```

### Note about objects

[](#note-about-objects)

The library takes terminology from Ramda. In most cases, it's perfectly fine, until one gets to the concept of *object*.

Ramda treats *objects* as dictionaries. In JavaScript, there's only one type which can act as a dictionary. It's ... `object`.

In PHP things get complicated. It's possible to use arrays and objects as dictionaries. This way `Phln` has to treat both of those types as an *object*.

For compatibility reason, all functions which return *object* will return `array`.

Testing
-------

[](#testing)

```
./vendor/bin/phpunit
```

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 99.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~168 days

Recently: every ~177 days

Total

8

Last Release

2049d ago

Major Versions

1.2.0 → 2.0.02018-10-21

2.x-dev → 3.x-dev2020-09-27

PHP version history (2 changes)2.0.0PHP &gt;=7.1

2.2.0PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/488bdbbb3187d1f4f6d9c92f0c716ad413f5e7fe53d3ec5ffefb37cfcad4ecf6?d=identicon)[radmen](/maintainers/radmen)

---

Top Contributors

[![radmen](https://avatars.githubusercontent.com/u/1190255?v=4)](https://github.com/radmen "radmen (156 commits)")[![jdreesen](https://avatars.githubusercontent.com/u/424602?v=4)](https://github.com/jdreesen "jdreesen (1 commits)")

---

Tags

fpfunction-phpfunctional-programmingphp

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/baethon-phln/health.svg)

```
[![Health](https://phpackages.com/badges/baethon-phln/health.svg)](https://phpackages.com/packages/baethon-phln)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
