{"id":15525154,"url":"https://github.com/antonioribeiro/coollection","last_synced_at":"2025-04-08T04:14:14.980Z","repository":{"id":26390719,"uuid":"108602178","full_name":"antonioribeiro/coollection","owner":"antonioribeiro","description":"Laravel Collection Objectified","archived":false,"fork":false,"pushed_at":"2024-10-28T12:58:56.000Z","size":208,"stargazers_count":95,"open_issues_count":1,"forks_count":27,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-01T03:34:30.626Z","etag":null,"topics":["collecion","laravel","laravel-collections","php"],"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/antonioribeiro.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-27T22:42:23.000Z","updated_at":"2024-12-19T06:29:08.000Z","dependencies_parsed_at":"2025-03-25T01:40:19.173Z","dependency_job_id":null,"html_url":"https://github.com/antonioribeiro/coollection","commit_stats":{"total_commits":128,"total_committers":3,"mean_commits":"42.666666666666664","dds":0.03125,"last_synced_commit":"ad641b9af271f9db95be5b0b2e1281caf48e501a"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonioribeiro%2Fcoollection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonioribeiro%2Fcoollection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonioribeiro%2Fcoollection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonioribeiro%2Fcoollection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antonioribeiro","download_url":"https://codeload.github.com/antonioribeiro/coollection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773719,"owners_count":20993639,"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":["collecion","laravel","laravel-collections","php"],"created_at":"2024-10-02T10:55:10.605Z","updated_at":"2025-04-08T04:14:14.925Z","avatar_url":"https://github.com/antonioribeiro.png","language":"PHP","readme":"# Coollection\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://packagist.org/packages/pragmarx/coollection\"\u003e\u003cimg alt=\"Latest Stable Version\" src=\"https://img.shields.io/packagist/v/pragmarx/coollection.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003ca href=\"LICENSE\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://scrutinizer-ci.com/g/antonioribeiro/coollection/?branch=master\"\u003e\u003cimg alt=\"Code Quality\" src=\"https://img.shields.io/scrutinizer/g/antonioribeiro/coollection.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://travis-ci.org/antonioribeiro/coollection\"\u003e\u003cimg alt=\"Build\" src=\"https://img.shields.io/travis/antonioribeiro/coollection.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/pragmarx/coollection\"\u003e\u003cimg alt=\"Downloads\" src=\"https://img.shields.io/packagist/dt/pragmarx/coollection.svg?style=flat-square\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://scrutinizer-ci.com/g/antonioribeiro/coollection/?branch=master\"\u003e\u003cimg alt=\"Coverage\" src=\"https://img.shields.io/scrutinizer/coverage/g/antonioribeiro/coollection.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://styleci.io/repos/108602178\"\u003e\u003cimg alt=\"StyleCI\" src=\"https://styleci.io/repos/108602178/shield\"\u003e\u003c/a\u003e\n    \u003c!-- \u003ca href=\"https://insight.sensiolabs.com/projects/156fbef1-b03f-4fca-ba97-57874b7a35bf\"\u003e\u003cimg alt=\"SensioLabsInsight\" src=\"https://img.shields.io/sensiolabs/i/156fbef1-b03f-4fca-ba97-57874b7a35bf.svg?style=flat-square\"\u003e\u003c/a\u003e --\u003e\n    \u003ca href=\"https://travis-ci.org/antonioribeiro/coollection\"\u003e\u003cimg alt=\"PHP\" src=\"https://img.shields.io/badge/PHP-7.0%20--%207.3-brightgreen.svg?style=flat-square\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n#### Access collection items as objects properties\n\nCoollection is [Laravel's Illuminate\\Collection](https://laravel.com/docs/5.5/collections) repackaged to be used as all properties were objects: \n\n``` php\n$collection-\u003ename\n\n$collection-\u003eaddresses-\u003efirst()-\u003estreet_name\n\n$collection-\u003eflatten()-\u003ecars-\u003efilter(function($car) { return $car-\u003ename == 'ferrari' })-\u003elast()-\u003emodel\n\n$countries-\u003ewhere('name.common', 'United States')-\u003efirst()-\u003ecurrency-\u003ename-\u003eenglish;\n```\n\n#### Tightenco\\Collect\n\nTo be agnostic and have complete idependence from Laravel's, but also to allow it to be used in Laravel applications, this package extends [Tightenco\\Collect](https://github.com/tightenco/collect), developed by [Matt Stauffer](https://twitter.com/stauffermatt) from [Tighten](https://twitter.com/tightenco). \n\n## Why?\n\n#### Answering with a question: which one is easier to look at?\n\n``` php\ncollect(\n    collect(\n        collect(\n            collect(\n                $collection['cars']\n            )-\u003eunique('constructor')['models']\n        )-\u003elast()['model']\n    )['colors']\n)-\u003efirst()['rgb']\n```\n\nor\n\n``` php\n$collection-\u003ecars-\u003eunique('constructor')-\u003elast()-\u003emodel-\u003ecolors-\u003efirst()-\u003ergb\n```\n\n#### Isn't this easier on the eyes?\n\n``` php\ncollect($vimeo)-\u003ebody-\u003edata-\u003efirst()-\u003emetadata-\u003econnections-\u003elikes-\u003etotal;\n```\n\nOr you prefer this one?\n\n\n``` php\ncollect($vimeo)['body']['data'][0]['metadata']['connections']['likes']['total'];\n```\n\n#### Used with Laravel request it is useful, if you receive:\n \n``` json\n{\"pagination\":{\"perPage\":100,\"pageNumber\":1}}\n```\n\nYou `collect()` it:\n\n``` php\n$input = coollect($request-\u003eall());\n```\n\nAnd you can just:\n\n``` php\n$input-\u003epagination-\u003eperPage\n```\n\nInstead of:\n\n``` php\n$input-\u003eget('pagination')['perPage']\n```\n\nYou can also use \"dot notation\" to get your items:\n\n``` php\n$input-\u003eget('pagination.perPage')\n```\n\n## PHP Agnostic\n\nThis is an agnostic PHP package, an extraction of Illuminate\\Support\\Collection with all needed classes, interfaces and traits. For that if you wish just to use Illuminate's Collection, you just have to import the class Collection:\n\n``` php\n$collection = new IlluminateExtracted\\Support\\Collection(['my collection']); \n```\n\nor use the usual helper:\n\n``` php\n$collection = collect(['my collection']); \n```\n\n## Documentation\n\nIt's Laravel's Collection, at full power, so you can check [its docs](https://laravel.com/docs/5.6/collections). The only difference is that you can access items (array keys) as properties, like any other PHP object:\n\n``` php\n$collection-\u003emap($mapper)-\u003ereduce($reducer)-\u003erandom()-\u003eaddress-\u003estreet\n\n$this-\u003esendThanks(\n    $collection-\u003ewhere('full_name', 'Barack Obama')-\u003eaddresses-\u003erandom()\n);    \n\n$countries-\u003ewhere('name.common', 'United States')-\u003efirst()-\u003ecurrency-\u003esymbol;\n```\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require pragmarx/coollection\n```\n\n## Usage\n\nInstantiate, the class directly or using the helper:\n\n``` php\n$c = new Coollection(['first_name' =\u003e 'Barack Obama']);\n\n$c = coollect(['first_name' =\u003e 'Barack Obama']);\n``` \n\nThen you use it as an object:\n\n``` php\necho $c-\u003efirst_name;\n\n// Barack Obama\n\n\necho $c-\u003eflip()-\u003ebarak_obama == 'first_name' \n    ? 'true' \n    : 'false';\n\n// true\n```\n\nOne word keys are case insensitive:\n\n``` php\necho $c-\u003erio;\necho $c-\u003eRIO;\n```\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email acr@antoniocarlosribeiro.com instead of using the issue tracker.\n\n## Credits\n\n- This package is an extension of [Tightenco\\Collect](https://github.com/tightenco/collect), developed by [Matt Stauffer](https://twitter.com/stauffermatt) from [Tighten](https://twitter.com/tightenco).\n- [Tightenco\\Collect](https://github.com/tightenco/collect) is an extraction of The Laravel Framework's Collection, created by [Taylor Otwell](https://twitter.com/taylorotwell).\n- Package creator [Antonio Carlos Ribeiro](https://twitter.com/iantonioribeiro)\n- [Contributors](https://github.com/antonioribeiro/ia-str/graphs/contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonioribeiro%2Fcoollection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonioribeiro%2Fcoollection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonioribeiro%2Fcoollection/lists"}