yellowcable / collection
Collection and Aggregation.
2.0.0
2024-03-12 10:37 UTC
Requires
- php: ^8.1
- ext-json: *
- ext-zlib: *
- laravel/serializable-closure: ^v1.3.2
Requires (Dev)
- phpmd/phpmd: ^2.15.0
- phpstan/phpstan: ^1.10.49
- phpunit/phpunit: ^10.4.2
- squizlabs/php_codesniffer: ^3.7.2
README
Collection and Aggregation library for PHP8.2+
Create object collections and be in control of iteration and access.
- You can either extend the abstract or implement and use the interfaces and traits.
- Aggregation is simple; it clears the content of the collections!
Usage
To use a Collection, make sure you create or instantiate:
$collection = new ItemCollection("test", [
new Item("1", 1, 1),
new Item("1", 1, 1),
new Item("1", 1, 1),
new Item("1", 1, 1),
]);
-----------------------------------------------
$collection = new class () extends Collection
{
public function getClass(): string
{
return Item::class;
}
};
Aggregations are possible in the same fashion as Collections:
$agg = new ItemAggregation("bliep");
$agg->addCollection(new ItemCollection("test", [new Item("item", 1, 1)]), false);
Notes
- Don't use stdClass if you want to serialize; PHP will not allow it.
Contribute
Contributions are always welcome! Suggestions are only welcome in the form of code.
License
To the extent possible under law, Yellow Cable has waived all copyright and related or neighboring rights to this work.