PHPackages                             danielefavi/fluent-api - 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. danielefavi/fluent-api

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

danielefavi/fluent-api
======================

Class designed for fluent API interface: you can invoke the same method statically and non-statically.

1.0.1(4y ago)116MITPHPPHP ^7.4|^8.0

Since Jan 15Pushed 4y ago1 watchersCompare

[ Source](https://github.com/danielefavi/php-fluent-api-package)[ Packagist](https://packagist.org/packages/danielefavi/fluent-api)[ RSS](/packages/danielefavi-fluent-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

php-fluent-api-package
======================

[](#php-fluent-api-package)

PHP package for fluent API interfaces: you can invoke a method both statically and non-statically.

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

[](#installation)

```
composer require danielefavi/fluent-api
```

Usage
-----

[](#usage)

### 1) Import the *FluentApi* class in the file you need it.

[](#1-import-the-fluentapi-class-in-the-file-you-need-it)

```
use DanieleFavi\FluentApi\FluentApi;
```

### 2) Extend your class with `FluentApi` class.

[](#2-extend-your-class-with-fluentapi-class)

```
class FluentMath extends FluentApi
{

}
```

### 3) Create your methods that can be invoked statically and non-statically.

[](#3-create-your-methods-that-can-be-invoked-statically-and-non-statically)

Declare the functions that can be called statically or non-statically with an underscore `_`.

In the example below the functions `add` and `subtract` can be invoked statically or non-statically.

```
class FluentMath extends FluentApi
{
    private $result = 0;

    protected function _add($num)
    {
        $this->result += $num;

        return $this;
    }

    protected function _subtract($num)
    {
        $this->result -= $num;

        return $this;
    }

    public function result()
    {
        return $this->result;
    }
}
```

### 4) Example of usage

[](#4-example-of-usage)

```
$res1 = FluentMath::add(5)
    ->add(3)
    ->subtract(2)
    ->add(8)
    ->result();

$res2 = FluentMath::subtract(1)
    ->add(10)
    ->result();

// $res1 equals to 14
// $res2 equals to 9
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

Every ~0 days

Total

2

Last Release

1583d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/31dc2af9124d4f028395fc040b9f07f31e93f9f395f37ed3bf4c10c87f708fe0?d=identicon)[DanieleFavi](/maintainers/DanieleFavi)

---

Top Contributors

[![danielefavi](https://avatars.githubusercontent.com/u/7241290?v=4)](https://github.com/danielefavi "danielefavi (1 commits)")

---

Tags

staticmethodfluent-apinon-static

### Embed Badge

![Health badge](/badges/danielefavi-fluent-api/health.svg)

```
[![Health](https://phpackages.com/badges/danielefavi-fluent-api/health.svg)](https://phpackages.com/packages/danielefavi-fluent-api)
```

###  Alternatives

[composer/satis

Simple Repository Generator

3.3k1.4M17](/packages/composer-satis)[sculpin/sculpin

Static Site Generator

1.5k102.8k12](/packages/sculpin-sculpin)[rybakit/arguments-resolver

ArgumentsResolver allows you to determine the arguments to pass to a function or method.

26107.7k7](/packages/rybakit-arguments-resolver)[norberttech/static-content-generator-bundle

Generate static html pages from your symfony application

373.7k](/packages/norberttech-static-content-generator-bundle)

PHPackages © 2026

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