PHPackages                             sigmaphp/sigmaphp-collections - 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. [Framework](/categories/framework)
4. /
5. sigmaphp/sigmaphp-collections

ActiveLibrary[Framework](/categories/framework)

sigmaphp/sigmaphp-collections
=============================

Collection Abstraction Library

0.1.0(2d ago)00MITPHPCI passing

Since Jun 17Pushed yesterdayCompare

[ Source](https://github.com/SigmaPHP/SigmaPHP-Collections)[ Packagist](https://packagist.org/packages/sigmaphp/sigmaphp-collections)[ RSS](/packages/sigmaphp-sigmaphp-collections/feed)WikiDiscussions master Synced today

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

SigmaPHP-Collections
====================

[](#sigmaphp-collections)

This library provides a powerful implementation of the `Collection` class, offering a rich set of functions that enable developers to work with arrays in PHP more efficiently. Since nearly everything in PHP can be represented as an array, managing them can sometimes become difficult and confusing, especially when working with the `array_*()` family of functions such as `array_map()` and `array_filter()`.

`SigmaPHP-Collections` addresses this challenge by introducing a utility data structure called `Collection`. It provides a wide range of features including method chaining, mapping, filtering, grouping, chunking, and iteration, allowing developers to work with arrays using a clean object-oriented approach rather than relying on complex and repetitive manual operations.

The `Collection` class supports all types of arrays and data structures. Collections can contain:

- Numeric arrays
- Associative arrays
- Objects
- Nested `Collection` instances

> **Note:** `Collection` is **mutable by default**, which means most operations will modify the underlying collection directly.
>
> However, the following methods are **immutable** and will always return a new `Collection` instance without affecting the original collection:
>
> - `where`
> - `chunk`
> - `groupBy`
> - `pluck`
> - `diff`
> - `reverse`
> - `flatten`
> - `partition`
> - `zip`
> - `unique`
> - `map`
> - `filter`
> - `slice`
>
> Keep this behavior in mind when working with collections to avoid unexpected mutations.

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

[](#installation)

```
composer require sigmaphp/sigmaphp-collections

```

Documentation
-------------

[](#documentation)

You can find below the complete list of available methods, along with an example for each one.

  [all](#all) [count](#count) [get](#get) [take](#take) [first](#first) [last](#last) [set](#set) [has](#has) [hasKey](#hasKey) [keys](#keys)   [values](#values) [remove](#remove) [clear](#clear) [every](#every) [contains](#contains) [partition](#partition) [where](#where) [push](#push) [pop](#pop) [unique](#unique)   [getIterator](#getIterator) [orderBy](#orderBy) [sort](#sort) [map](#map) [filter](#filter) [reduce](#reduce) [merge](#merge) [shuffle](#shuffle) [toJson](#toJson) [slice](#slice)   [range](#range) [times](#times) [isEmpty](#isEmpty) [isNotEmpty](#isNotEmpty) [avg](#avg) [max](#max) [min](#min) [sum](#sum) [random](#random) [chunk](#chunk)   [each](#each) [groupBy](#groupBy) [pluck](#pluck) [diff](#diff) [reverse](#reverse) [toString](#toString) [make](#make) [flatten](#flatten) [pad](#pad) [zip](#zip) ### all

[](#all)

Get all items stored inside the collection.

```
