collection

Provides a Collection implementation for PHP

BSD-3-CLAUSE License

Downloads
1.6M
Stars
2
Committers
1

Collection

Provides a Collection implementation for PHP.

Installation

You can install the package via composer:

composer require ghostwriter/collection

Star ⭐️ this repo if you find it useful

You can also star (🌟) this repo to find it easier later.

Usage

/** @var \Ghostwriter\Collection\Collection $collection */
$collection = Collection::new([1, 2, 3])
    ->append([4, 5, 6, 7, 8, 9])
    ->map(static fn ($v): int => $v * 10)
    ->filter(static fn ($v): bool => 0 === $v % 20);
    
$collection->toArray();  // [20, 40, 60, 80]
$collection->drop(1)     // [40, 60, 80]
           ->take(2)     // [40, 60]
           ->slice(1, 1) // [60]
           ->toArray();  // [60]

Credits

Thank you

Thank you for freely sharing your knowledge, insight and free time with me. I am grateful for your help and support.

Changelog

Please see CHANGELOG.md for more information on what has changed recently.

License

Please see LICENSE for more information on the license that applies to this project.

Security

Please see SECURITY.md for more information on security disclosure process.