{"id":28324193,"url":"https://github.com/softboxlab/php-collection-helper","last_synced_at":"2025-09-09T06:16:34.453Z","repository":{"id":57054877,"uuid":"94136483","full_name":"SoftboxLab/php-collection-helper","owner":"SoftboxLab","description":"Simple PHP helper collection","archived":false,"fork":false,"pushed_at":"2017-06-16T13:41:31.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-02T02:11:31.348Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/SoftboxLab.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-06-12T20:15:01.000Z","updated_at":"2017-06-13T03:23:04.000Z","dependencies_parsed_at":"2022-08-24T03:41:01.261Z","dependency_job_id":null,"html_url":"https://github.com/SoftboxLab/php-collection-helper","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/SoftboxLab/php-collection-helper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftboxLab%2Fphp-collection-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftboxLab%2Fphp-collection-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftboxLab%2Fphp-collection-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftboxLab%2Fphp-collection-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SoftboxLab","download_url":"https://codeload.github.com/SoftboxLab/php-collection-helper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftboxLab%2Fphp-collection-helper/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261591681,"owners_count":23181773,"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":[],"created_at":"2025-05-25T17:10:37.315Z","updated_at":"2025-06-24T02:31:34.722Z","avatar_url":"https://github.com/SoftboxLab.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/SoftboxLab/php-collection-helper.svg?branch=master)](https://travis-ci.org/SoftboxLab/php-collection-helper)\n[![codecov](https://codecov.io/gh/SoftboxLab/php-collection-helper/branch/master/graph/badge.svg)](https://codecov.io/gh/SoftboxLab/php-collection-helper)\n\n# Simple PHP Collection and array helper\nSimple collection class to work with arrays on object-oriented paradigm and some array (collection) helpers with standardization of the parameters (data first, callback later, like *javascript*).\n\n## Collection\nIn this definition, our collection is *Immutable*, which means that *every* operation should return a new collection, keeping the original collection intact.\n\n```php\n$collection = new Collection([1, 2, 3, 4]);\n$newCollection = $collection-\u003emap(function ($item) {\n    return $item * 2;\n});\n\nprint_r($newCollection-\u003eall()); // [2, 4, 6, 8]\nprint_r($collection-\u003eall()); // [1, 2, 3, 4]\n```\n\n## Collection helper\nThis is the base support to the Collection class. All the methods are implemented here.\n\n### List of available methods\n- map($data, $callback ($value, $key));\n  - Map all the items of data with the provided callback. The callback will receive both value's and key's of the array.\n- filter($data, $callback($value, $key), $keepKeys);\n  - Filter the given array with the provided callback. Only the items when the callback return's true will be returned on the filtered data. If false is passed to *keepKeys* parameter, the keys will be reseted.\n- reduce($data, $callback($value, $key), $initialValue);\n  - Reduce's the given data with the given callback.\n- transform($data, $changes, $delimiter);\n  - Transform the keys (change) of the given `$data` array with the `$changes` array. To navigate along the array, use the Laravel's dot syntax. If `$delimiter` provided, it changed the Laravel's dot syntax separator.\n- transformArray($data, $changed, $delimiter);\n  - Same as transform, but should be used on a list, which will apply on every item. Same as map with transform.\n\n## Transformer class\nSimple array transformer class, which convert all the keys by new ones. Something like a `from-to` where the all the keys of the given array will be replaced the by the value of the given replaced array when the key matches.\n\nExample:\n\n```php\n$transformer = new Transformer(['namae' =\u003e 'nombre']);\n$data = ['namae' =\u003e 'William'];\n$transformedData = $transformer-\u003etransform($data);\n\nprint_r($transformedData); // ['nombre' =\u003e 'William'];\n```\n\n## Contributing\nFeel free to make any pull request you judge necessary!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftboxlab%2Fphp-collection-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftboxlab%2Fphp-collection-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftboxlab%2Fphp-collection-helper/lists"}