wearesho-team / base-collection
Typed collection based on ArrayObject
Installs: 2 018
Dependents: 7
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 1
Open Issues: 8
Requires
- php: ^7.4 || ^8.0
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.7
This package is auto-updated.
Last update: 2024-10-29 04:25:47 UTC
README
Implementation of typed collection.
Installation
composer require wearesho-team/base-collection
Usage
Create your class collection and implement type()
method.
It must return declared (existed) class name
<?php use Wearesho\BaseCollection; class MyCollection extends BaseCollection { public function type(): string { return stdClass::class; } }
And now you have typed collection!
If you try to append item that not instance of your type you will catch an InvalidArgumentException