PHPackages                             adhocore/with - 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. adhocore/with

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

adhocore/with
=============

With provides object like fluent interface for scalars and non objects

v0.0.3(8y ago)17293[1 PRs](https://github.com/adhocore/with/pulls)MITPHP

Since Aug 26Pushed 3y ago1 watchersCompare

[ Source](https://github.com/adhocore/with)[ Packagist](https://packagist.org/packages/adhocore/with)[ RSS](/packages/adhocore-with/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (3)Dependencies (1)Versions (6)Used By (0)

adhocore/with
-------------

[](#adhocorewith)

[![Latest Version](https://camo.githubusercontent.com/fa0083929e23f954591c5f6ef13b1c8ba754490ea4af10c8b3d1821d412088fd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6164686f636f72652f776974682e7376673f7374796c653d666c61742d737175617265)](https://github.com/adhocore/with/releases)[![Travis Build](https://camo.githubusercontent.com/df1d832d502f695f6a528005864ed0a044edef3bedb2e6cb26cea14215b69c8d/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6164686f636f72652f776974682f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/adhocore/with?branch=master)[![Scrutinizer CI](https://camo.githubusercontent.com/2c0e5b0eb59c1c707992a6cd7be27785d98358b8f37d692b352c48c9802dfa3d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6164686f636f72652f776974682e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/adhocore/with/?branch=master)[![Codecov branch](https://camo.githubusercontent.com/6fb80652afafd54625b687c2ab85a18187995b9b23d4cafe2f022f06e71a7537/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6164686f636f72652f776974682f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/adhocore/with)[![StyleCI](https://camo.githubusercontent.com/29a1b2d4500266af6e5901de5289d7f700a699db6b1053a9d62d0a6a2dabe2dc/68747470733a2f2f7374796c6563692e696f2f7265706f732f3130313438323332352f736869656c64)](https://styleci.io/repos/101482325)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

- Objectify scalars and non objects
- Fluent method chaining instead of nested function calls
- For PHP7

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

[](#installation)

```
composer require adhocore/with
```

Usage
-----

[](#usage)

```
use function Ahc\with;
// OR
use Ahc\With\With;

$val  = ['a' => 10, 'b' => 12, 'c' => 13];
$with = with($val) // OR (new With($val))
    ->array_values()
    // _ at the end means the current value is appended to the supplied arguments (default is prepend).
    ->array_map_(function ($v) { return $v + 2; })
    ->array_sum()
;

// Get the final result
echo $with(); // 41

// Passing value through closures or class methods:
with($value)->via(function ($val) { return $val; });
with($value)->via([new SomeClass, 'method']);
```

Why
---

[](#why)

**TL;DR**: Provides more intuitiveness, comprehensibility and less cognitive overhead than nested function calls.

Did you ever had to pass a scalar/non-object through many layers of functions? Then you might have probably ended up with having to call the first the function which had to be called at the last logically. For example if you want to sum the keys of an array after adding 2 to them?

```
// Without:
array_sum(array_map(function ($a) { return $a + 2; }, array_keys($array)));

// With:
with($array)->array_keys()->array_map_(function ($a) { return $a + 2; })->array_sum();
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.7% 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 ~31 days

Total

3

Last Release

3170d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2908547?v=4)[Jitendra Adhikari](/maintainers/adhocore)[@adhocore](https://github.com/adhocore)

---

Top Contributors

[![adhocore](https://avatars.githubusercontent.com/u/2908547?v=4)](https://github.com/adhocore "adhocore (22 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

adhocorefluent-interfacemethod-chainingphp7scalar-objectsfluentwithscalar-objectsscalar-methods

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/adhocore-with/health.svg)

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

###  Alternatives

[samrap/acf-fluent

A fluent interface for the Advanced Custom Fields WordPress plugin

28357.5k4](/packages/samrap-acf-fluent)[fab2s/yaetl

Widely Extended Nodal Extract-Transform-Load ETL Workflow AKA NEJQTL or Nodal-Extract-Join-Qualify-Tranform-Load

66191.9k](/packages/fab2s-yaetl)

PHPackages © 2026

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