{"id":17858533,"url":"https://github.com/oved-php/typed-collections","last_synced_at":"2025-03-20T16:32:40.586Z","repository":{"id":57040898,"uuid":"81723300","full_name":"OveD-php/typed-collections","owner":"OveD-php","description":"A simple library to create type hinted collections in PHP- build on Laravals Collection class","archived":false,"fork":false,"pushed_at":"2020-04-22T20:31:57.000Z","size":62,"stargazers_count":10,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-17T17:38:38.254Z","etag":null,"topics":["collections","laravel","laravel-collections","php-library","php7","type-hints","type-safe"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OveD-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-12T12:11:08.000Z","updated_at":"2023-08-22T00:35:42.000Z","dependencies_parsed_at":"2022-08-24T01:10:36.658Z","dependency_job_id":null,"html_url":"https://github.com/OveD-php/typed-collections","commit_stats":null,"previous_names":["vistik/typed-collections"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OveD-php%2Ftyped-collections","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OveD-php%2Ftyped-collections/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OveD-php%2Ftyped-collections/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OveD-php%2Ftyped-collections/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OveD-php","download_url":"https://codeload.github.com/OveD-php/typed-collections/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244650073,"owners_count":20487557,"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":["collections","laravel","laravel-collections","php-library","php7","type-hints","type-safe"],"created_at":"2024-10-28T05:09:21.113Z","updated_at":"2025-03-20T16:32:40.581Z","avatar_url":"https://github.com/OveD-php.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/vistik/typed-collections.svg?branch=master)](https://travis-ci.org/vistik/typed-collections)\n\n### What is this?\n\nThis is a very simple way to make arrays type hinted!\n\n`$list = new UserCollection(new User());`\n\nOK\n\n`$list = new UserCollection('User');`\n\nWill throw:\n\n`Vistik\\Exception\\InvalidTypeException: Item (string) 'User' is not a Vistik\\Example\\User object!`\n\n### Install\nRun `composer require vistik/typed-collections`\n\n### Use build in Collections for primitives\nOut-of-the-box collections for:\n - Booleans\n - Integers\n - Floats\n - Strings\n - Emails\n - Numbers (float or int)\n \nThey can be created with out-of-the-box laraval style helpers:\n\n- `bCollect([true, false])` - To create a BoolCollection\n- `iCollect([1, 2, 3, 4])` - To create a IntegerCollection\n- `fCollect([3.14, 22/7, 6.66])` - To create a FloatCollection\n- `sCollect(['hello', 'world''])` - To create a StringCollection\n- `eCollect(['hello@example.org', 'write@me.com'])` - To create a EmailCollection\n- `nCollect([1, 2, 3, 4, 3.14, INF])` - To create a NumberCollection\n\n### Do I have to create a type for each list? Yes, but\nLook how easy it is:\n\n    use Phpsafari\\Example\\User;\n    class UserCollection extends TypedCollection{\n        protected $type = User::class;\n    }\n\n2 simple steps\n\n1) Create a Class eg. `AccountCollection` extend `TypedCollection`  \n2) Just replace `protected $type = 'Vistik\\Example\\User';` with your class\n\nor\n\nIf the check is more then just a `is_a` check, you can overwrite the function: `isValidItem($item)` in your new Collection class\n\n### Features\n\n* Build upon [Illuminate\\Support\\Collection](https://github.com/illuminate/support)\n* Very simple to implement custom Collections\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foved-php%2Ftyped-collections","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foved-php%2Ftyped-collections","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foved-php%2Ftyped-collections/lists"}