PHPackages                             pulli/collection-macros - 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. pulli/collection-macros

Abandoned → [pulli/laravel-collection-macros](/?search=pulli%2Flaravel-collection-macros)Library[Utility &amp; Helpers](/categories/utility)

pulli/collection-macros
=======================

Macros for the Laravel/Illuminate collection class

v0.2.9(6mo ago)01.5kMITPHPPHP &gt;=8.2CI passing

Since Sep 12Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/the-pulli/collection-macros)[ Packagist](https://packagist.org/packages/pulli/collection-macros)[ Docs](https://github.com/the-pulli/collection-macros)[ RSS](/packages/pulli-collection-macros/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (8)Dependencies (4)Versions (14)Used By (0)

Useful Laravel collection macros
================================

[](#useful-laravel-collection-macros)

[![release](https://camo.githubusercontent.com/13997fe851d1caa6257f4c9111c0f5c908b4309fad9c87c334416b970646fbe4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7468652d70756c6c692f636f6c6c656374696f6e2d6d6163726f732e7376673f7374796c653d666c61742d737175617265)](https://github.com/the-pulli/collection-macros/releases)[![packagist](https://camo.githubusercontent.com/ebc8ee506db109003012a7b847a5ce19ae90137c11da4bde69d913173a926d2a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70756c6c692f636f6c6c656374696f6e2d6d6163726f732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pulli/collection-macros)[![license](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/the-pulli/collection-macros/blob/main/LICENSE.md)[![downloads](https://camo.githubusercontent.com/f70ac500a64c674a82a082a3378ffa3b2daaaaf73133725162a57a8458a921dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70756c6c692f636f6c6c656374696f6e2d6d6163726f732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pulli/collection-macros)[![tests](https://github.com/the-pulli/collection-macros/actions/workflows/ci.yml/badge.svg)](https://github.com/the-pulli/collection-macros/actions/workflows/ci.yml/badge.svg)

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

[](#installation)

You can pull in the package via composer:

```
composer require pulli/collection-macros
```

Macros
------

[](#macros)

- mapToCollectionFrom
- mapToCollection
- positive
- recursiveToArrayFrom
- recursiveToArray

### `mapToCollectionFrom`

[](#maptocollectionfrom)

Static method: Maps all arrays/objects recursively to a collection object of collections, which allow nested function calling.

```
$collection = Collection::mapToCollectionFrom([['test' => 1], 2, 3]);

$collection->get(0)->get('test'); // returns 1

// Item has a toArray() public method, then it can be wrapped into a collection like this:
$collection = Collection::mapToCollectionFrom([Item(), Item()], true);
```

### `positive`

[](#positive)

Returns a boolean value, if the collection contains elements or not.

```
Collection::make([1, 2, 3])->positive() // returns true
Collection::make()->positive() // returns false
```

### `recursiveToArrayFrom`

[](#recursivetoarrayfrom)

Static method: Like `mapToCollectionFrom` it maps all arrays/objects recursively to an array.

```
// Item has a toArray() public method, then it can be wrapped into the collection like this:
$array = Collection::recursiveToArrayFrom(['item1' => Item(), 'item2' => Item()]);
```

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance69

Regular maintenance activity

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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 ~69 days

Recently: every ~76 days

Total

13

Last Release

180d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c14e16040b5b84e5c91af8c7a39480567d951bfc27673f97d9c75480dbe20b5e?d=identicon)[pulli](/maintainers/pulli)

---

Top Contributors

[![the-pulli](https://avatars.githubusercontent.com/u/112799107?v=4)](https://github.com/the-pulli "the-pulli (21 commits)")

---

Tags

pullicollection-macros

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/pulli-collection-macros/health.svg)

```
[![Health](https://phpackages.com/badges/pulli-collection-macros/health.svg)](https://phpackages.com/packages/pulli-collection-macros)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[illuminate/pipeline

The Illuminate Pipeline package.

9348.3M267](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10533.5M989](/packages/illuminate-pagination)[illuminate/redis

The Illuminate Redis package.

8314.4M362](/packages/illuminate-redis)[illuminate/cookie

The Illuminate Cookie package.

224.5M132](/packages/illuminate-cookie)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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