webtheory/collection

Create typed collections and defer logic to collection kernel

0.5.4 2022-06-28 04:04 UTC

This package is auto-updated.

Last update: 2024-12-10 02:23:29 UTC


README

A message to Russian 🇷🇺 people

If you currently live in Russia, please read this message.

Stand With Ukraine

Stand With Ukraine Latest Version on Packagist Build Status Code Quality Code Coverage Total Downloads Software License Required PHP Version

Purpose

This package facilitates the creation of typed collections without having to duplicate underlying logic. Due to PHP's enforcement of Liskov Substitution Principle via method covariance and contravariance, it's not possible to create a natively typed collection using inheritance so long as you need methods that operate on specific types. This package provides a configurable 'collection kernel' class that stores and performs operations on a given array. Rather than inheritance, this paradigm uses composition to fulfil basic collection functionality. Besides enabling strong typing, one of the many benefits of this approach is that you have complete control over the operations to be exposed by your collections.

Installation

Via Composer

composer require webtheory/collection

Usage


Change log

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

Testing

composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email spider.mane.web@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.