DEV Community

Cover image for Small Collection 2.0 is out
sebk69
sebk69

Posted on

Small Collection 2.0 is out

small-collection provide generic collection classes.

Natively, it provide :

  • Generic collections
  • Numeric collections
  • String collections

You can also select your collection as it was a database table :

(new NumericCollection(
    (new CollectionSelector(
        (new CollectionsToRecords([
            ['field1' => 'value1', 'field2' => 1],
            ['field1' => 'value2', 'field2' => 2],
            ['field1' => 'value3', 'field2' => 3],
            ['field1' => 'value4', 'field2' => 4],
            ['field1' => 'value5', 'field2' => 5],
        ]))->transform()
    ))->where()
        ->firstCondition(
            new Condition(
                new ConditionElement(ConditionElementType::var, 'field2'),
                ConditionOperator::inferior,
                new ConditionElement(ConditionElementType::const, 4),
            )
        )->execute()
    ->resolvePath(explode('.', '*.field2'))
))->sum()
Enter fullscreen mode Exit fullscreen mode

See documentation for all features

Git repository : https://git.small-project.dev/lib/small-collection
Packagist : small/collection

Top comments (0)