PHPackages                             inmanturbo/functional-library - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. inmanturbo/functional-library

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

inmanturbo/functional-library
=============================

create Closure libraries with ease for functional programming with php

v1.0.0(1y ago)233MITPHPPHP ^8.1

Since Aug 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/inmanturbo/functional-library)[ Packagist](https://packagist.org/packages/inmanturbo/functional-library)[ Docs](https://github.com/inmanturbo/functional-library)[ RSS](/packages/inmanturbo-functional-library/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

create closure libraries with ease for functional programming with php
======================================================================

[](#create-closure-libraries-with-ease-for-functional-programming-with-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d33c4109db7a3320d83290e5e719f0da8c6d9de43177389342cfbdb1d6ad958a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e6d616e747572626f2f66756e6374696f6e616c2d6c6962726172792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/inmanturbo/functional-library)[![Tests](https://camo.githubusercontent.com/809c17fe8e30f111e512bcd54ce3188a6b24fce597b962c252e9f2f8250a0d9a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f696e6d616e747572626f2f66756e6374696f6e616c2d6c6962726172792f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/inmanturbo/functional-library/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/41488fd3ed530874dcf4117be922a159c19e4302ffc32b86c96e0c747eee315d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696e6d616e747572626f2f66756e6374696f6e616c2d6c6962726172792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/inmanturbo/functional-library)

This package makes it easy to export and autoload a library of anonymous functions or collections of anonymous functions using composer.

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

[](#installation)

You can install the package via composer:

```
composer require inmanturbo/functional-library
```

Usage
-----

[](#usage)

To create a library you can use the `HasFunctionalLibrary` trait, then you just have to implement a static library method with named bool parameters for your available functions.

You then call `static::getLibrary` with all your parameters as its `args`.

Finally, you create a static method called `closures()` with an associative array of your anonymous functions with (string) keys corresponding to your library method's named params.

Example
-------

[](#example)

```
use Inmanturbo\FunctionalLibrary\HasFunctionalLibrary;

class ExampleLibrary
{
    use HasFunctionalLibrary;

    public static function library(bool $addOne = false, bool $addTwo = false)
    {
        return static::getLibrary(...func_get_args());
    }

    public static function closures()
    {
        return [
            'addOne' => fn(int $number): int => $number + 1,
            'addTwo' => fn(int $number): int => $number + 2,
        ];
    }
}
```

Example Usage
-------------

[](#example-usage)

The above example creates the following testable api (using pest):

```
[$addOne, $addTwo] = ExampleLibrary::library(addOne: true, addTwo: true);
expect($addOne(0))->toBe(1);
expect($addTwo(0))->toBe(2);

// Test a single option
$addOne = ExampleLibrary::library(addOne: true);

expect($addOne(0))->toBe(1);

// Test no options (should return all available options)
[$addOne, $addTwo] = ExampleLibrary::library();

expect($addOne(0))->toBe(1);
expect($addTwo(0))->toBe(2);
```

Now you can put your anonymous functions into scoped static libraries and find them using static analysis by their named arguments, or by inspecting the `closures()` method's return value.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [inmanturbo](https://github.com/inmanturbo)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

639d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0261babef618b8fb3bfcea84376ed5e71e7169586eb8de63a6550c2e7ea653a6?d=identicon)[inmanturbo](/maintainers/inmanturbo)

---

Top Contributors

[![inmanturbo](https://avatars.githubusercontent.com/u/47095624?v=4)](https://github.com/inmanturbo "inmanturbo (21 commits)")

---

Tags

inmanturbofunctional-library

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/inmanturbo-functional-library/health.svg)

```
[![Health](https://phpackages.com/badges/inmanturbo-functional-library/health.svg)](https://phpackages.com/packages/inmanturbo-functional-library)
```

PHPackages © 2026

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