{"id":23058289,"url":"https://github.com/germaniakg/filteriterators","last_synced_at":"2025-06-30T13:39:35.078Z","repository":{"id":37733340,"uuid":"69455063","full_name":"GermaniaKG/FilterIterators","owner":"GermaniaKG","description":"FilterIterators for two-dimensional Traversables.","archived":false,"fork":false,"pushed_at":"2023-04-19T20:44:18.000Z","size":154,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-08T20:12:43.313Z","etag":null,"topics":["filter","iterator","traversable"],"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/GermaniaKG.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"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":"2016-09-28T11:05:37.000Z","updated_at":"2022-03-30T09:11:41.000Z","dependencies_parsed_at":"2025-02-08T20:12:32.947Z","dependency_job_id":"a0748b40-5255-4236-82c7-0b77577e1f47","html_url":"https://github.com/GermaniaKG/FilterIterators","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GermaniaKG%2FFilterIterators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GermaniaKG%2FFilterIterators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GermaniaKG%2FFilterIterators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GermaniaKG%2FFilterIterators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GermaniaKG","download_url":"https://codeload.github.com/GermaniaKG/FilterIterators/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246944385,"owners_count":20858772,"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":["filter","iterator","traversable"],"created_at":"2024-12-16T02:15:01.657Z","updated_at":"2025-04-03T06:16:42.601Z","avatar_url":"https://github.com/GermaniaKG.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://static.germania-kg.com/logos/ga-logo-2016-web.svgz\" width=\"250px\"\u003e\n\n------\n\n\n# Germania KG · FilterIterators\n\n**FilterIterators for two-dimensional Traversables.**\n\n[![Packagist](https://img.shields.io/packagist/v/germania-kg/filteriterators.svg?style=flat)](https://packagist.org/packages/germania-kg/filteriterators)\n[![PHP version](https://img.shields.io/packagist/php-v/germania-kg/filteriterators.svg)](https://packagist.org/packages/germania-kg/filteriterators)\n[![Tests](https://github.com/GermaniaKG/FilterIterators/actions/workflows/php.yml/badge.svg)](https://github.com/GermaniaKG/FilterIterators/actions/workflows/php.yml)\n\n## Installation with Composer\n\n```bash\n$ composer require germania-kg/filteriterators\n```\n\nAlternatively, add this package directly to your *composer.json:*\n\n```json\n\"require\": {\n    \"germania-kg/filteriterators\": \"^2.0\"\n}\n```\n\n\n\n## BlankSplitFilterIterator\n\nLets all items pass of which the given field, splitted by *blank* sign into an array, contains a word.\nThe Constructor accepts anything that is Traversable.   \nThe Traversable may contain both arrays or (StdClass) objects.\n\n```php\n\u003c?php\nuse Germania\\FilterIterators\\BlankSplitFilterIterator;\n \n$items = array(\n  [ 'foo' =\u003e 'bar john doe'],\n  [ 'foo' =\u003e 'john bar doe'],\n  [ 'foo' =\u003e 'john doe bar'],\n  [ 'foo' =\u003e ['john', 'doe', 'bar']],\n);  \n\n// Convert above arrays to StdClasses\n$objects = array_map(function ($a) { return (object) $a; }, $items);\n\n$filter = new BlankSplitFilterIterator( $items, \"foo\", \"bar\" );\necho iterator_count( $filter ); // 4\n\n$filter = new BlankSplitFilterIterator( $objects, \"foo\", \"bar\" );\necho iterator_count( $filter ); // 4\n```\n\n\n\n\n\n## WordRegexFilterIterator\n\nLets all items pass of which the given field matches a word.\nThe Constructor accepts anything that is Traversable.   \nThe Traversable may contain both arrays or (StdClass) objects.\n\n```php\n\u003c?php\nuse Germania\\FilterIterators\\WordRegexFilterIterator;\n\n$items = array(\n  [ 'foo' =\u003e 'bar john doe'],\n  [ 'foo' =\u003e 'john bar doe'],\n  [ 'foo' =\u003e 'john doe bar'],\n  [ 'foo' =\u003e 'bar,john,doe'],\n  [ 'foo' =\u003e 'john,bar,doe'],\n  [ 'foo' =\u003e 'john,doe,bar'],\n  [ 'foo' =\u003e 'john,doe,white-bar'],\n  [ 'foo' =\u003e 'john,doe,bar-black']\n);\n\n// Convert above arrays to StdClasses\n$objects = array_map(function ($a) { return (object) $a; }, $items);\n\n$filter = new WordRegexFilterIterator( $items, \"foo\", \"bar\" );\necho iterator_count( $filter ); // 8\n\n$filter = new WordRegexFilterIterator( $objects, \"foo\", \"bar\" );\necho iterator_count( $filter ); // 8\n```\n\n\n\n## KeyNotFalseFilterIterator\n\nLets all items pass that are not explicitely excluded with `active=false` or `active=0`.   \nThe Constructor accepts anything that is Traversable.   \nThe Traversable may contain both arrays or (StdClass) objects.\n\n```php\n\u003c?php\nuse Germania\\FilterIterators\\KeyNotFalseFilterIterator;\n\n// Items may be Arrays or StdClass objects\n$data = [\n  // These are not \"inactive\"\n  [ 'name' =\u003e 'John', 'active' =\u003e true ],\n  [ 'name' =\u003e 'George' ],\n\n  // but these are:\n  [ 'name' =\u003e 'Paul',  'active' =\u003e false ],\n  [ 'name' =\u003e 'Ringo', 'active' =\u003e 0 ],\n];\n\n$filter = new KeyNotFalseFilterIterator( $data, \"active\" );\nforeach( $filter as $item ):\n\t// John\n\t// George\n\techo $item['name'];\nendforeach;\n```\n\n## NotEmptyFieldFilterIterator\n\nLets all items pass that have a field whose value is not empty.  \nThe Constructor accepts anything that is Traversable.  \nThe Traversable may contain both arrays or (StdClass) objects.  \n\n```php\n\u003c?php\nuse Germania\\FilterIterators\\NotEmptyFieldFilterIterator;\n\n// Items may be Arrays or StdClass objects\n$data = [\n  // These are not \"inactive\"\n  [ 'name' =\u003e 'John', 'active' =\u003e true ],\n  [ 'name' =\u003e 'George' ],\n\n  // but these are:\n  [ 'name' =\u003e 'Paul',  'active' =\u003e false ],\n  [ 'name' =\u003e 'Ringo', 'active' =\u003e 0 ],\n];\n\n$filter = new NotEmptyFieldFilterIterator( $data, \"active\" );\nforeach( $filter as $item ):\n\t// John\n\techo $item['name'];\nendforeach;\n```\n\n## Issues\n\nSee [issues list.][i0]\n\n[i0]: https://github.com/GermaniaKG/FilterIterators/issues\n\n\n## Development\n\n```bash\n$ git clone https://github.com/GermaniaKG/FilterIterators.git\n$ cd FilterIterators\n$ composer install\n```\n\n## Unit tests\n\nEither copy `phpunit.xml.dist` to `phpunit.xml` and adapt to your needs, or leave as is. Run [PhpUnit](https://phpunit.de/) test or composer scripts like this:\n\n```bash\n$ composer test\n# or\n$ vendor/bin/phpunit\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgermaniakg%2Ffilteriterators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgermaniakg%2Ffilteriterators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgermaniakg%2Ffilteriterators/lists"}