PHPackages                             cscfa\_tool\_division/collections - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. cscfa\_tool\_division/collections

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

cscfa\_tool\_division/collections
=================================

This bundle provide collections class and method to store data

V1.0.1(9y ago)01532MITPHP

Since Nov 29Pushed 9y ago1 watchersCompare

[ Source](https://github.com/cscfaToolDivision/collections)[ Packagist](https://packagist.org/packages/cscfa_tool_division/collections)[ Docs](http://cscfa.fr)[ RSS](/packages/cscfa-tool-division-collections/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (1)Versions (2)Used By (2)

collections
===========

[](#collections)

This bundle provide a set of collection class to abstract the usage of the array and provide advanced inheritance and logic.

Structure of a collection
-------------------------

[](#structure-of-a-collection)

The collections of this bundle are created from the following architecture :

- Interface
- Method traits
- Abstract class
- Concrete class

The Interface are childs of the CollectionInterface and defined the public methods of the collections.

The method trait define the logic of the collections. They need a 'content' property to be used. So the functionnal storage property of a collection must be named 'content' and be an array.

The Abstract class is a container for the traits and define the 'content' property.

The Concrete class is usable 'as it'.

Available collections
---------------------

[](#available-collections)

#### Abstract collection

[](#abstract-collection)

methodpurposereturntraitclear()clear the collection contentreturn an array representative of the content before clearClearableCollectionTraitcontain($element)check if the collection contain a specified valueTRUE if it contain or FALSEContainerCollectionTraitcontainAll(array $elements)as 'contain' but for a set of valueas 'contain' method. Return TRUE if all values are containedContainerCollectionTraitisEmpty()check if the collection is empty or notTRUE if the collection is empty or FALSENumberizedCollectionTraitcount()return the count of elements into the collectionthe count as integerNumberizedCollectionTraittoArray()normalize the current collection to arraythe representative array of the collectionArrayContentCollectionTrait#### Value collection

[](#value-collection)

methodpurposereturntraitclear()clear the collection contentreturn an array representative of the content before clearClearableCollectionTraitcontain($element)check if the collection contain a specified valueTRUE if it contain or FALSEContainerCollectionTraitcontainAll(array $elements)as 'contain' but for a set of valueas 'contain' method. Return TRUE if all values are containedContainerCollectionTraitisEmpty()check if the collection is empty or notTRUE if the collection is empty or FALSENumberizedCollectionTraitcount()return the count of elements into the collectionthe count as integerNumberizedCollectionTraittoArray()normalize the current collection to arraythe representative array of the collectionArrayContentCollectionTraitadd($value)add a value to the collectionreturn itself to allow chained callValueCollectionTraitaddAll(array $values)as add, but for a set of valueas addValueCollectionTraitremove($value)remove a value from the collectionreturn the deleted element or NULL if not currently storedValueCollectionTraitremoveAll(array $value)as remove but for a set of valuereturn an array containing the deleted elements. Can be emptyValueCollectionTrait#### Map collection

[](#map-collection)

methodpurposereturntraitclear()clear the collection contentreturn an array representative of the content before clearClearableCollectionTraitcontain($element)check if the collection contain a specified valueTRUE if it contain or FALSEContainerCollectionTraitcontainAll(array $elements)as 'contain' but for a set of valueas 'contain' method. Return TRUE if all values are containedContainerCollectionTraitisEmpty()check if the collection is empty or notTRUE if the collection is empty or FALSENumberizedCollectionTraitcount()return the count of elements into the collectionthe count as integerNumberizedCollectionTraittoArray()normalize the current collection to arraythe representative array of the collectionArrayContentCollectionTraithas()check if the collection contain a specified keyTRUE if the key exist, or FALSEMapCollectionTraitget($key)get the content of a key from the collectionthe content of the key, or NULL if not currently storedMapCollectionTraitset($key, $value)set the content for a given key or create it if not currently storedthe collection to allow chained callMapCollectionTraitsetAll(array $assocArray)as set, but for an associative arrayas setMapCollectionTraitremove($key)remove a key from the collectionreturn the content of the key before deletion, or NULL if not currently storedMapCollectionTraitremoveAll(array $keys)as remove but for a set of keysreturn an array of values corresponding to the deleted key valuesMapCollectionTrait#### Container collection

[](#container-collection)

methodpurposereturntraitclear()clear the collection contentreturn an array representative of the content before clearClearableCollectionTraitcontain($element)check if the collection contain a specified valueTRUE if it contain or FALSEContainerCollectionTraitcontainAll(array $elements)as 'contain' but for a set of valueas 'contain' method. Return TRUE if all values are containedContainerCollectionTraitisEmpty()check if the collection is empty or notTRUE if the collection is empty or FALSENumberizedCollectionTraitcount()return the count of elements into the collectionthe count as integerNumberizedCollectionTraittoArray()normalize the current collection to arraythe representative array of the collectionArrayContentCollectionTraithas()check if the collection contain a specified keyTRUE if the key exist, or FALSEMapCollectionTraitget($key)get the content of a key from the collectionthe content of the key, or NULL if not currently storedMapCollectionTraitset($key, $value)set the content for a given key or create it if not currently storedthe collection to allow chained callMapCollectionTraitsetAll(array $assocArray)as set, but for an associative arrayas setMapCollectionTraitremove($key)remove a key from the collectionreturn the content of the key before deletion, or NULL if not currently storedMapCollectionTraitremoveAll(array $keys)as remove but for a set of keysreturn an array of values corresponding to the deleted key valuesMapCollectionTraitgetSubset($key)create a subset of the key contentreturn a ContainerCollectionInterface containing the value of the key, or an empty one if the key does not exist on is not an array or a CllectionInterfaceSubsetableCollectionTrait#### Value set

[](#value-set)

methodpurposereturntraitclear()clear the collection contentreturn an array representative of the content before clearClearableCollectionTraitcontain($element)check if the collection contain a specified valueTRUE if it contain or FALSEContainerCollectionTraitcontainAll(array $elements)as 'contain' but for a set of valueas 'contain' method. Return TRUE if all values are containedContainerCollectionTraitisEmpty()check if the collection is empty or notTRUE if the collection is empty or FALSENumberizedCollectionTraitcount()return the count of elements into the collectionthe count as integerNumberizedCollectionTraittoArray()normalize the current collection to arraythe representative array of the collectionArrayContentCollectionTraitadd($value)add a value to the collection. It will not be inserted if it not unique in the current content without throwing any exceptionreturn itself to allow chained callValueCollectionTraitaddAll(array $values)as add, but for a set of valueas addValueCollectionTraitremove($value)remove a value from the collectionreturn the deleted element or NULL if not currently storedValueCollectionTraitremoveAll(array $value)as remove but for a set of valuereturn an array containing the deleted elements. Can be emptyValueCollectionTraitThe collection helper
---------------------

[](#the-collection-helper)

The collection helper take care of the advanced behaviour of the collection logic. It allow to merge, cut, traverse and create collections from array. This helper is a service and can be getted by it's id 'collection.helper.std'.

You will be able to use the following methods :

methodpurposeargumentsreturnarrayToCollectioncreate a collection from an arraysource array, collection classname to createan instance of the needed collectionmergeCollectionsmerge to collections instancefirst collection, second collectiona collection of the first collection given type with the content of the two collectionsmergeArraymerge a collection and an arraycollection, arraya collection of the given collection type with the content of the collection and the arraysubCollectioncreate a new collection from a collection with a subset of the contentcollection, start index, lengthreturn a collection of the given collection type with the content from the started integer index with the given lengthsubMapcreate a new collection from a collection with the intersection of the given keys as contentcollection, array of needed keysreturn a collection of the given collection type with the keys that exists into the given collection and the key arraywalkCollectionexecute a given function for all of the elements of the given collection. The given function will receive the value, the key and the given argument array in this order as argumentcollection, function, argument arraynothingTo work fine, the collection helper need a array caster that support the given collection. If you create your own collection and want to use it into the helper, you must create an array caster for your collection. Note the existing casters support the MapCollectionInterface childs and ValueCollectionInterfaceChilds.

#### Create an array caster

[](#create-an-array-caster)

The array caster need to implement the ArrayCasterInterface. It define two methods :

- support($class) : check if the given class name is supported by the array caster. It must return true or false.
- toCollection(array $array, $class) : create a collection of the given class with the content of the array as content.

After your caster created, you must register it at a service, with the 'collection.helper.caster' tag. The bundle will automatically register it into the array caster manager of the helpers.

A note of quality check
-----------------------

[](#a-note-of-quality-check)

[![SensioLabsInsight](https://camo.githubusercontent.com/5b475b576d337b31deca7d90fe70adefae4a0aacf923bc4b4bcff0fe2bfb01b2/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f35663538373161612d353936392d343434312d613530392d3565623739616661633361342f6d696e692e706e67)](https://insight.sensiolabs.com/projects/5f5871aa-5969-4441-a509-5eb79afac3a4)

✅ phpcs tested

✅ phpmd tested (full rules)

✅ phpdcd tested

✅ phpcpd tested

✅ phpunit tested (code coverage done)

See the doc :

- [code coverage](https://cdn.rawgit.com/cscfaToolDivision/collections/master/doc/coverage.html/index.html)
- [code documentation](https://cdn.rawgit.com/cscfaToolDivision/collections/master/doc/phpdox/html/namespaces.xhtml)

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3500d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12436206?v=4)[cscfa](/maintainers/cscfa)[@cscfa](https://github.com/cscfa)

---

Top Contributors

[![matthieu88160](https://avatars.githubusercontent.com/u/11874266?v=4)](https://github.com/matthieu88160 "matthieu88160 (30 commits)")

---

Tags

bundletoolcollectioncollectionsdivisioncscfa

### Embed Badge

![Health badge](/badges/cscfa-tool-division-collections/health.svg)

```
[![Health](https://phpackages.com/badges/cscfa-tool-division-collections/health.svg)](https://phpackages.com/packages/cscfa-tool-division-collections)
```

###  Alternatives

[rotexsoft/versatile-collections

A collection package that can be extended to implement things such as a Dependency Injection Container, RecordSet objects for housing database records, a bag of http cookies, or technically any collection of items that can be looped over and whose items can each be accessed using array-access syntax or object property syntax.

186.1k1](/packages/rotexsoft-versatile-collections)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
