{"id":27091734,"url":"https://github.com/dgame/php-iterator","last_synced_at":"2025-09-03T22:34:17.568Z","repository":{"id":56967359,"uuid":"61667694","full_name":"Dgame/php-iterator","owner":"Dgame","description":null,"archived":false,"fork":false,"pushed_at":"2021-10-23T21:19:08.000Z","size":72,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T07:53:29.158Z","etag":null,"topics":["functional-programming","high-order","iterator","php"],"latest_commit_sha":null,"homepage":null,"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/Dgame.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":"2016-06-21T21:15:50.000Z","updated_at":"2023-03-05T03:25:21.000Z","dependencies_parsed_at":"2022-08-21T09:50:48.419Z","dependency_job_id":null,"html_url":"https://github.com/Dgame/php-iterator","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/Dgame/php-iterator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dgame%2Fphp-iterator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dgame%2Fphp-iterator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dgame%2Fphp-iterator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dgame%2Fphp-iterator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dgame","download_url":"https://codeload.github.com/Dgame/php-iterator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dgame%2Fphp-iterator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273523088,"owners_count":25120859,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["functional-programming","high-order","iterator","php"],"created_at":"2025-04-06T07:53:32.523Z","updated_at":"2025-09-03T22:34:17.544Z","avatar_url":"https://github.com/Dgame.png","language":"PHP","readme":"# php-iterator\n\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Dgame/php-iterator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Dgame/php-iterator/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/Dgame/php-iterator/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Dgame/php-iterator/?branch=master)\n[![Build Status](https://scrutinizer-ci.com/g/Dgame/php-iterator/badges/build.png?b=master)](https://scrutinizer-ci.com/g/Dgame/php-iterator/build-status/master)\n[![StyleCI](https://styleci.io/repos/61667694/shield?branch=master)](https://styleci.io/repos/61667694)\n[![Build Status](https://travis-ci.org/Dgame/php-iterator.svg?branch=master)](https://travis-ci.org/Dgame/php-iterator)\n\n## Enjoy high order functions\n\n### only \u0026 repeat\n```php\n$this-\u003eassertEquals('aaaa', only('a')-\u003erepeat(4)-\u003eimplode());\n```\n\n### take\n```php\n$this-\u003eassertEquals('Hal', chars('Hallo')-\u003etake(3)-\u003eimplode());\n```\n\n### skip\n```php\n$this-\u003eassertEquals('lo', chars('Hallo')-\u003eskip(3)-\u003eimplode());\n```\n\n### slice\n```php\n$this-\u003eassertEquals('oBar', chars('FooBarQuatz')-\u003eslice(2, 6)-\u003eimplode());\n```\n\n### chunks\n```php\n$this-\u003eassertEquals([['F', 'o'], ['o', 'B'], ['a', 'r']], chars('FooBar')-\u003echunks(2)-\u003ecollect());\n```\n\n### fold\n```php\n$it = iter([6, 7, 8]);\n\n$sum1 = function($sum, int $a) {\n    return $sum + $a;\n};\n\n$sum2 = function(int $sum, int $a) {\n    return $sum + $a;\n};\n\n$this-\u003eassertEquals(21, $it-\u003efold($sum1));\n$this-\u003eassertEquals(63, $it-\u003efold($sum2, 42));\n```\n\n### take while\n```php\n$belowTen = function (int $item) {\n    return $item \u003c 10;\n};\n\n$this-\u003eassertEquals([0, 1, 2], iter([0, 1, 2, 10, 20])-\u003etakeWhile($belowTen)-\u003ecollect());\n```\n\n### skip while\n```php\n$belowTen = function (int $item) {\n    return $item \u003c 10;\n};\n\n$this-\u003eassertEquals([10, 20], iter([0, 1, 2, 10, 20])-\u003eskipWhile($belowTen)-\u003ecollect());\n```\n\n### before\n```php\n$this-\u003eassertEquals('ab', chars('abcdef')-\u003ebefore('c')-\u003eimplode());\n```\n\n```php\n$this-\u003eassertEquals(['a' =\u003e 'z', 'b' =\u003e 'y'], iter(['a' =\u003e 'z', 'b' =\u003e 'y', 'c' =\u003e 'x', 'd' =\u003e 'w'])-\u003ebefore('x')-\u003ecollect());\n```\n\n### after\n```php\n$this-\u003eassertEquals('ef', chars('abcdef')-\u003eafter('d')-\u003eimplode());\n```\n\n```php\n$this-\u003eassertEquals(['d' =\u003e 'w'], iter(['a' =\u003e 'z', 'b' =\u003e 'y', 'c' =\u003e 'x', 'd' =\u003e 'w'])-\u003eafter('x')-\u003ecollect());\n```\n\n### from\n```php\n$this-\u003eassertEquals('def', chars('abcdef')-\u003efrom('d')-\u003eimplode());\n```\n\n```php\n$this-\u003eassertEquals(['c' =\u003e 'x', 'd' =\u003e 'w'], iter(['a' =\u003e 'z', 'b' =\u003e 'y', 'c' =\u003e 'x', 'd' =\u003e 'w'])-\u003efrom('x')-\u003ecollect());\n```\n\n### until\n```php\n$this-\u003eassertEquals('abc', chars('abcdef')-\u003euntil('c')-\u003eimplode());\n```\n\n```php\n$this-\u003eassertEquals(['a' =\u003e 'z', 'b' =\u003e 'y', 'c' =\u003e 'x'], iter(['a' =\u003e 'z', 'b' =\u003e 'y', 'c' =\u003e 'x', 'd' =\u003e 'w'])-\u003euntil('x')-\u003ecollect());\n```\n\n### all\n```php\n$positive = function (int $item) {\n    return $item \u003e= 0;\n};\n\n$this-\u003eassertTrue(iter([0, 1, 2, 3])-\u003eall($positive));\n$this-\u003eassertFalse(iter([-1, 2, 3, 4])-\u003eall($positive));\n```\n\n### any\n```php\n$positive = function (int $item) {\n    return $item \u003e 0;\n};\n\n$this-\u003eassertTrue(iter([-1, 0, 1])-\u003eany($positive));\n$this-\u003eassertFalse(iter([-1])-\u003eany($positive));\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgame%2Fphp-iterator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgame%2Fphp-iterator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgame%2Fphp-iterator/lists"}