webtheory / collection
Create typed collections and defer logic to collection kernel
Requires
- php: ^7.4 || ^8.0
- symfony/polyfill-php80: ^1.23
- symfony/polyfill-php81: ^1.23
Requires (Dev)
- captainhook/captainhook: ^5.10
- dflydev/dot-access-data: ^3.0
- fakerphp/faker: ^1.16
- friendsofphp/php-cs-fixer: ^3.4
- jawira/case-converter: ^3.4
- mockery/mockery: ^1.4
- myclabs/php-enum: ^1.8
- oscarotero/env: ^2.1
- phpbench/phpbench: @dev
- phpcompatibility/php-compatibility: ^9.3
- phpspec/prophecy-phpunit: ^2.0
- phpstan/phpstan: ^1.6
- phpunit/phpunit: ^9.5
- psy/psysh: ^0.11
- rector/rector: ^0.12.20
- spatie/phpunit-watcher: ^1.12
- squizlabs/php_codesniffer: ^3.5
- symfony/console: ^5.4
- symfony/thanks: ^1.1
- vimeo/psalm: ^4.22
- vlucas/phpdotenv: ^5.4
- webtheory/exterminate: @stable
README
A message to Russian 🇷🇺 people
If you currently live in Russia, please read this message.
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.