{"id":21638781,"url":"https://github.com/novactive/novacollection","last_synced_at":"2025-04-11T16:51:21.091Z","repository":{"id":51993272,"uuid":"79615518","full_name":"Novactive/NovaCollection","owner":"Novactive","description":"Collection implementation that wraps regular PHP arrays.","archived":false,"fork":false,"pushed_at":"2021-03-08T21:59:17.000Z","size":201,"stargazers_count":9,"open_issues_count":8,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-25T12:53:34.293Z","etag":null,"topics":["array","collection","functional-programming","php","php7","symfony"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Novactive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-21T01:35:10.000Z","updated_at":"2022-09-03T16:59:46.000Z","dependencies_parsed_at":"2022-08-23T16:20:28.116Z","dependency_job_id":null,"html_url":"https://github.com/Novactive/NovaCollection","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Novactive%2FNovaCollection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Novactive%2FNovaCollection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Novactive%2FNovaCollection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Novactive%2FNovaCollection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Novactive","download_url":"https://codeload.github.com/Novactive/NovaCollection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248442999,"owners_count":21104314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array","collection","functional-programming","php","php7","symfony"],"created_at":"2024-11-25T04:11:38.247Z","updated_at":"2025-04-11T16:51:21.070Z","avatar_url":"https://github.com/Novactive.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"| Branch   | Travis | Sensio Insight | Scrutinizer Quality | Scrutinizer Coverage  |\n|:--------:|:------:|:--------------:|:-------------------:|:---------------------:|\n| develop  | [![Build Status](https://travis-ci.org/Novactive/NovaCollection.svg?branch=develop)](https://travis-ci.org/Novactive/NovaCollection) | [![SensioLabsInsight](https://insight.sensiolabs.com/projects/0d53485d-5fbf-46a0-a1c2-c5c879a78b1e/mini.png)](https://insight.sensiolabs.com/projects/0d53485d-5fbf-46a0-a1c2-c5c879a78b1e) | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Novactive/NovaCollection/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/Novactive/NovaCollection/?branch=develop) |  [![Code Coverage](https://scrutinizer-ci.com/g/Novactive/NovaCollection/badges/coverage.png?b=develop)](https://scrutinizer-ci.com/g/Novactive/NovaCollection/?branch=develop)\n| master   | [![Build Status](https://travis-ci.org/Novactive/NovaCollection.svg?branch=master)](https://travis-ci.org/Novactive/NovaCollection)  | [![SensioLabsInsight](https://insight.sensiolabs.com/projects/8276b281-ea82-423c-8725-b6e9163260de/mini.png)](https://insight.sensiolabs.com/projects/8276b281-ea82-423c-8725-b6e9163260de)|  [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Novactive/NovaCollection/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Novactive/NovaCollection/?branch=master) |  [![Code Coverage](https://scrutinizer-ci.com/g/Novactive/NovaCollection/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Novactive/NovaCollection/?branch=master)\n\n# Nova Collection\n\nBecause we did not find any *Collection* for PHP as simple as we wanted, we did ours.\n\n## Simpler, Better, Faster, Stronger\n\nUsing *array_** functions against *foreach* is not an easy pick. As this library is made to manage low level actions.\nWe wanted it to be fast, then we compared and we implemented the best choices. (have a look: [PHP7.2](https://i.imgur.com/JUUo6EE.png))\n\nFully unit tested it is reliable.\n\n## Methods\n\n### Advanced Selection by range\n\n```php\n$collection = NovaCollection([0,1,2,3,4,5,6,7,8,9,10]);\n$collection([2,4], 1, 2, '4-2', '3,2;5-2;10')-\u003etoArray();\n```\n\u003e Result: [2,3,4,1,2,4,3,2,3,4,5,4,3,2,10]\n\n\n### Standard Manipulation Methods\n\n| Method                                                       | Description                                                                                           |\n|--------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|\n| toArray()                                                    | Get the raw Array.                                                                                    |\n| set($key, $value)                                            | Set the value to the key no matter what.                                                              |\n| get($key, $default)                                          | Get the value related to the key.                                                                     |\n| atIndex(int $index)                                          | Get the item at the given index (numerically).                                                        |\n| keyOf($value)                                                | Get the key of a value if exists.                                                                     |\n| indexOf($value)                                              | Get the index of a value if exists (numerically).                                                     |\n| containsKey($key)                                            | Test is the key exists.                                                                               |\n| contains($value)                                             | Test if this values exists.                                                                           |\n| add($item)                                                   | Add a new value to the collection, next numeric index will be used. (in-place).                       |\n| append(iterable $values)                                     | Append the items at the end of the collection not regarding the keys. (in-place).                     |\n| clear()                                                      | Clear the collection of all its items. (in-place).                                                    |\n| remove($key)                                                 | Remove the $key/value in the collection. (in-place).                                                  |\n| pull($key)                                                   | Remove the $key/value in the collection and return the removed value. (in-place).                     |\n| first(callable $callback)                                    | Get the first time and reset and rewind.                                                              |\n| shift()                                                      | Shift an element off the beginning of the collection. (in-place).                                     |\n| pop()                                                        | Shift an element off the end of the collection. (in-place).                                           |\n| last(callable $callback)                                     | Get the last item.                                                                                    |\n| map(callable $callback)                                      | Map and return a new Collection.                                                                      |\n| mapKeys(callable $callback, callable $callbackValue)         | Map keys (and/or value) and return a new Collection.                                                  |\n| transform(callable $callback)                                | Map. (in-place).                                                                                      |\n| filter(callable $callback)                                   | Filter and return a new Collection.                                                                   |\n| prune(callable $callback)                                    | Filter. (in-place).                                                                                   |\n| combine(iterable $values, bool $inPlace)                     | Combine and return a new Collection.                                                                  |\n| replace(iterable $values)                                    | Combine. (in-place).                                                                                  |\n| combineKeys(iterable $keys)                                  | Opposite of Combine It keeps the values of the current Collection and assign new keys.                |\n| reindex(iterable $keys)                                      | CombineKeys. (in-place).                                                                              |\n| reduce(callable $callback, $initial)                         | Reduce.                                                                                               |\n| each(callable $callback)                                     | Run the callback on each element. (passive).                                                          |\n| flip()                                                       | Flip the keys and the values and return a new Collection.                                             |\n| invert()                                                     | Flip. (in-place).                                                                                     |\n| merge(iterable $items, bool $inPlace)                        | Merge the items and the collections and return a new Collection.                                      |\n| coalesce(iterable $items)                                    | Merge. (in-place).                                                                                    |\n| union(iterable $items, bool $inPlace)                        | Union the collection with Items and return a new Collection.                                          |\n| absorb(iterable $items)                                      | Union. (in-place).                                                                                    |\n| assert(callable $callback, bool $expected)                   | Assert that the callback result is $expected for all.                                                 |\n| values()                                                     | Return all the values.                                                                                |\n| keys()                                                       | Return all the keys.                                                                                  |\n| pipe(callable $callback)                                     | Pass the collection to the given callback and return the result.                                      |\n| shuffle()                                                    | Random. (in-place).                                                                                   |\n| random()                                                     | Shuffle and return a new Collection.                                                                  |\n| unique()                                                     | Deduplicate the collection and return a new Collection.                                               |\n| implode(string $separator)                                   | Join the items using the $separator.                                                                  |\n| distinct()                                                   | Unique. (in-place).                                                                                   |\n| zip(iterable $items)                                         | Merge the values items by items and return a new Collection.                                          |\n| reverse()                                                    | Reverse the collection and return a new Collection.                                                   |\n| inverse()                                                    | Reverse. (in-place).                                                                                  |\n| isEmpty()                                                    | Tells if the collection is empty.                                                                     |\n| split(int $count)                                            | Split in the collection in $count parts and return a new Collection.                                  |\n| chunk(int $size)                                             | Chunk of $size sub collection and return a new Collection.                                            |\n| slice(int $offset, int $length)                              | Get a slice of the collection and inject it in a new Collection.                                      |\n| keep(int $offset, int $length)                               | Keep a slice of the collection. (in-place).                                                           |\n| applyOn($key, callable $onKeyFound, callable $onKeyNotFound) | Apply the callback $onKeyFound on the key/value if the key exists. (passive).                         |\n| cut(int $offset, int $length)                                | Cut a slice of the collection. (in-place).                                                            |\n| diff(iterable $items)                                        | Compares the collection against $items and returns the values that are not present in the collection. |\n| diffKeys(iterable $items)                                    | Compares the collection against $items and returns the keys that are not present in the collection.   |\n| intersect(iterable $items)                                   | Compares the collection against $items and returns the values that exist in the collection.           |\n| intersectKeys(iterable $items)                               | Compares the collection against $items and returns the keys that exist in the collection.             |\n| exists(callable $callback)                                   | Return true if one item return true to the callback.                                                  |\n\n## Contributing\n\nIn order to be accepted, your contribution needs to pass a few controls: \n\n* PHP files should be valid\n* PHP files should follow the [PSR-2](http://www.php-fig.org/psr/psr-2/) standard\n* PHP files should be [phpmd](https://phpmd.org) and [phpcpd](https://github.com/sebastianbergmann/phpcpd) warning/error free\n\nTo ease the validation process, you can use these 2 scripts:\n\n### Coding Standards and syntax\n\n```bash\nmake codeclean\n```\n\u003e will check and fix the Coding Standards\n\n### Tests\n\n```bash\nmake tests\n```\n\u003e will run the tests\n\n## Changelog\n\n[Changelog](doc/CHANGELOG.md)\n\n\n## LICENSE\n\n[License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovactive%2Fnovacollection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnovactive%2Fnovacollection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovactive%2Fnovacollection/lists"}