PHPackages                             ericpoe/haystack - 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. ericpoe/haystack

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

ericpoe/haystack
================

Forget Haystack vs Needle order, the object IS the Haystack. Haystack is a library that allows for pipelining and immutable structures.

v2.1.3(7y ago)3729.4k↓100%1[1 issues](https://github.com/ericpoe/haystack/issues)MITPHPPHP ^5.6 || ^7.0CI failing

Since Jul 27Pushed 4y ago3 watchersCompare

[ Source](https://github.com/ericpoe/haystack)[ Packagist](https://packagist.org/packages/ericpoe/haystack)[ RSS](/packages/ericpoe-haystack/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (15)Used By (0)

[![GitHub Workflow Status for Code Testing (master branch)](https://camo.githubusercontent.com/421980fbdf86639da7604fad995ec8e9eadb2a7c639d6790dca64de5d9543282/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f65726963706f652f686179737461636b2f556e697425323054657374696e672f6d61737465723f6c6162656c3d556e697425323054657374696e67267374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/421980fbdf86639da7604fad995ec8e9eadb2a7c639d6790dca64de5d9543282/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f65726963706f652f686179737461636b2f556e697425323054657374696e672f6d61737465723f6c6162656c3d556e697425323054657374696e67267374796c653d666c61742d737175617265)[![GitHub Workflow Status for Code Analysis (master branch)](https://camo.githubusercontent.com/1c6151fcc67384a63058fc7e77c267143eec6b82d846b3dd78e4214a0c76fbcb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f65726963706f652f686179737461636b2f436f6465253230416e616c797369732f6d61737465723f6c6162656c3d436f6465253230416e616c79736973267374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/1c6151fcc67384a63058fc7e77c267143eec6b82d846b3dd78e4214a0c76fbcb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f65726963706f652f686179737461636b2f436f6465253230416e616c797369732f6d61737465723f6c6162656c3d436f6465253230416e616c79736973267374796c653d666c61742d737175617265)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Packagist Version](https://camo.githubusercontent.com/ea3bd6e4cb8f1e19c7dd95cace11d86edc2633bdf72954941a7d83064aa25e08/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f65726963706f652f686179737461636b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ericpoe/haystack)

Haystack
========

[](#haystack)

Forget Haystack vs Needle order, the object *IS* the Haystack. Haystack is a library that allows for pipelining, immutable structures, and UTF-8 strings.

Install
-------

[](#install)

Haystack is installable as a [Composer](http://getcomposer.org) package:

```
$ composer require ericpoe/haystack
```

Running tests
-------------

[](#running-tests)

```
$ git clone ...
$ composer install
$ vendor/bin/phpunit
```

Background
----------

[](#background)

Trying to remember commonly-used PHP functions for strings and arrays in PHP is hard. Are array functions haystack-needle and string functions needle-haystack, or vice versa? Quick, without looking at documentation or using a decent IDE, which is correct: `in_array($needle, $haystack)` or `in_array($haystack, needle)`?

Also, even though many of the same kinds of functions are run against arrays and strings, the function names are wildly different. `strstr` and `in_array` do similar things, yet have different names and are called in different manners.

Goal
----

[](#goal)

This project will attempt to match as many string and array verbs as possible. For example, `$foo->contains("elvis")`should determine if the string "elvis" is contained in the $foo object, it shouldn't matter if `$foo` is a string or an array. Ditto `$foo->map($callable)` and `$foo->filter($callable)`.

How do I?
---------

[](#how-do-i)

Check out the [manual](docs/manual.md) for all the things you can do with the Haystack library.

###  Health Score

37

—

LowBetter than 84% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 96.8% 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 ~116 days

Recently: every ~195 days

Total

12

Last Release

2609d ago

Major Versions

v0.3.0 → v1.0.02016-02-16

v1.0.2 → v2.0.02016-12-09

PHP version history (4 changes)v0.1.0PHP &gt;=5.4.0

v0.3.0PHP &gt;=5.6.0

v2.0.0PHP &gt;=5.5.9

v2.1.0PHP ^5.6 || ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/95adab63f0338b13354b5680bd46bae7cec1d0635f8734231dad935cb378078b?d=identicon)[ericpoe](/maintainers/ericpoe)

---

Top Contributors

[![ericpoe](https://avatars.githubusercontent.com/u/1981351?v=4)](https://github.com/ericpoe "ericpoe (389 commits)")[![johnkary](https://avatars.githubusercontent.com/u/135607?v=4)](https://github.com/johnkary "johnkary (13 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ericpoe-haystack/health.svg)

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

PHPackages © 2026

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