{"id":19904164,"url":"https://github.com/bertptrs/phpstreams","last_synced_at":"2025-05-03T00:31:31.777Z","repository":{"id":56950746,"uuid":"61710082","full_name":"bertptrs/phpstreams","owner":"bertptrs","description":"A streams library for PHP inspired by the Java 8 Streams API.","archived":false,"fork":false,"pushed_at":"2018-12-28T21:10:20.000Z","size":32,"stargazers_count":87,"open_issues_count":1,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-07T09:02:07.502Z","etag":null,"topics":["java-streams","php","stream"],"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/bertptrs.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":"2016-06-22T10:23:05.000Z","updated_at":"2025-02-03T15:16:40.000Z","dependencies_parsed_at":"2022-08-21T08:21:00.126Z","dependency_job_id":null,"html_url":"https://github.com/bertptrs/phpstreams","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bertptrs%2Fphpstreams","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bertptrs%2Fphpstreams/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bertptrs%2Fphpstreams/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bertptrs%2Fphpstreams/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bertptrs","download_url":"https://codeload.github.com/bertptrs/phpstreams/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252126537,"owners_count":21698963,"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":["java-streams","php","stream"],"created_at":"2024-11-12T20:27:10.502Z","updated_at":"2025-05-03T00:31:30.648Z","avatar_url":"https://github.com/bertptrs.png","language":"PHP","readme":"# PHPStreams\n\n[![Latest Stable Version](https://poser.pugx.org/bertptrs/phpstreams/v/stable)](https://packagist.org/packages/bertptrs/phpstreams) [![Total Downloads](https://poser.pugx.org/bertptrs/phpstreams/downloads)](https://packagist.org/packages/bertptrs/phpstreams) [![License](https://poser.pugx.org/bertptrs/phpstreams/license)](https://packagist.org/packages/bertptrs/phpstreams) [![Build Status](https://travis-ci.org/bertptrs/phpstreams.svg?branch=master)](https://travis-ci.org/bertptrs/phpstreams)\n\nA partial implementation of the Java 8 Streams API in PHP. PHPStreams\ncan use your generators, your arrays and really anything that is\n[Iterable](https://wiki.php.net/rfc/iterable) and convert modify it like\nyou're used to using Java Streams!\n\nUsing streams and generators, you can easily sort through large amounts\nof data without having to have it all in memory or in scope. Streams\nalso make it easier to structure your code, by (more or less) enforcing\nsingle resposibility.\n\nThe library is compatible with PHP 5.5.9 and up.\n\n## Installation\n\nPHPStreams can be installed using Composer. Just run `composer require\nbertptrs/phpstreams` in your project root!\n\n## Usage\n\nUsing streams is easy. Say, we want the first 7 odd numbers in the\nFibonacci sequence. To do this using Streams, we do the following:\n\n```php\n// Define a generator for Fibonacci numbers\nfunction fibonacci()\n{\n    yield 0;\n    yield 1;\n\n    $prev = 0;\n    $cur = 1;\n\n    while (true) {\n        yield ($new = $cur + $prev);\n        $prev = $cur;\n        $cur = $new;\n    }\n};\n\n// Define a predicate that checks for odd numbers\n$isOdd = function($num) {\n    return $num % 2 == 1;\n};\n\n// Create our stream.\n$stream = new phpstreams\\Stream(fibonacci());\n\n// Finally, use these to create our result.\n$oddFibo = $stream-\u003efilter($isOdd)  // Keep only the odd numbers\n    -\u003elimit(8)                      // Limit our results\n    -\u003etoArray(false);               // Convert to array, discarding keys\n```\n\n## Documentation\n\nDocumentation is mostly done using PHPDoc. I do intend to write actual\ndocumtation if there is any interest.\n\n## Contributing\n\nI welcome contributions and pull requests. Please note that I do follow\nPSR-2 (and PSR-4 for autoloading). Also, please submit unit tests with\nyour work.\n\nGrumPHP enforces at least part of the coding standard, but do make an\neffort to structure your contributions nicely.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbertptrs%2Fphpstreams","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbertptrs%2Fphpstreams","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbertptrs%2Fphpstreams/lists"}