amo/collection

Collection Abstraction library extended

v0.0.4 2022-04-20 07:24 UTC

This package is not auto-updated.

Last update: 2024-05-01 17:29:23 UTC


README

Collection management, heavily inspired by Doctrine ArrayCollection

Install

composer require amo/collection

Usages

// Static instantiation
Collection::make($repository->findBy($criterias))
    // map method, allows to create a new collection 
    // based on each item of the given collection 
    ->map(function(User $user){
        return $user->getEmail();
    })
    // each method, executes a closure fore each item of a collection
    ->each(function(String $email) {
        $message = $this->buildMessage($email);
        $this->mailer->send($message);
    });
    // etc...