{"id":17437124,"url":"https://github.com/nabeghe/yielder-php","last_synced_at":"2025-07-30T13:18:01.216Z","repository":{"id":258539740,"uuid":"871226048","full_name":"nabeghe/yielder-php","owner":"nabeghe","description":"A similar alternative to yield in PHP for reading values from arrays, with a touch of zest.","archived":false,"fork":false,"pushed_at":"2025-07-03T14:22:28.000Z","size":11,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-20T03:24:01.575Z","etag":null,"topics":["array","lazy-loading","lazyload","library","php","yield","yielder"],"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/nabeghe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2024-10-11T14:15:11.000Z","updated_at":"2025-07-03T14:22:31.000Z","dependencies_parsed_at":"2024-10-21T13:05:59.976Z","dependency_job_id":null,"html_url":"https://github.com/nabeghe/yielder-php","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"09b65d22f15755a19d670299890966da0e2ec962"},"previous_names":["nabeghe/yielder-php"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/nabeghe/yielder-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeghe%2Fyielder-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeghe%2Fyielder-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeghe%2Fyielder-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeghe%2Fyielder-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nabeghe","download_url":"https://codeload.github.com/nabeghe/yielder-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeghe%2Fyielder-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267874514,"owners_count":24158765,"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-07-30T02:00:09.044Z","response_time":70,"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":["array","lazy-loading","lazyload","library","php","yield","yielder"],"created_at":"2024-10-17T11:05:53.773Z","updated_at":"2025-07-30T13:18:00.510Z","avatar_url":"https://github.com/nabeghe.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yielder for PHP ≥ 7.4\n\n\u003e A similar alternative to yield in PHP for reading values from arrays, with a touch of zest.\n\nRetrieve the value of the next index in an array whenever you want,\nor define the values as callables so that their contents can be returned when needed.\nThis is likely just the beginning or the end of this package library!\n\n## 🫡 Usage\n\n### 🚀 Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require nabeghe/yielder\n```\n\n### Example 1: Value\n\nEach time, the array returns the value of the next index.\n\n```php\nuse Nabeghe\\Yielder\\Yielder;\n\n$data = [\n    'value 1',\n    'value 2',\n    'value 3',\n];\n\n$value = Yielder::value($data, $index);\necho \"Index $index: $value\\n\"; // Index 0: value 1\n\n$value = Yielder::value($data, $index);\necho \"Index $index: $value\\n\"; // Index 1: value 2\n\n$value = Yielder::value($data, $index);\necho \"Index $index: $value\\n\"; // Index 2: value 3\n\n$value = Yielder::value($data, $index);\necho \"Index $index: $value\\n\"; // Index -1: null\n\nYielder::reset($data);\n\n$value = Yielder::value($data, $index);\necho \"Index $index: $value\\n\"; // Index 0: value 1\n```\n\n### Example 2: Each\n\nIterating through the array using the `value` method.\n\n```php\n$data = [\n    'value 1',\n    'value 2',\n    'value 3',\n];\n\nYielder::each($data, function ($value, $index) {\n    echo \"Index $index: $value\\n\";\n    // return true if you want to break.\n});\n```\n\n### Example 3: Value Call\n\nImagine you have an array that contains data,\nbut instead of placing the data directly in each index,\nyou can define them as callables.\nThis way, they can be executed when needed, returning their values.\n\nThis is something like lazy loading.\n\n```php\nuse Nabeghe\\Yielder\\Yielder;\n\n$data = [\n    function () {\n        return 'Value 1';\n    },\n    function () {\n        return 'Value 2';\n    },\n    function () {\n        return 'Value 3';\n    },\n];\n\n$value = Yielder::valueCall($data, $index);\necho \"Index $index: $value\\n\"; // Index 0: value 1\n\n$value = Yielder::valueCall($data, $index);\necho \"Index $index: $value\\n\"; // Index 1: value 2\n\n$value = Yielder::valueCall($data, $index);\necho \"Index $index: $value\\n\"; // Index 2: value 3\n\n$value = Yielder::valueCall($data, $index);\necho \"Index $index: $value\\n\"; // Index -1: null\n\nYielder::reset($data);\n\n$value = Yielder::valueCall($data, $index);\necho \"Index $index: $value\\n\"; // Index 0: value 1\n```\n\n### Example 4: Each Call\n\nIterating through the array, but exactly like `valueCall`.\n\n```php\nuse Nabeghe\\Yielder\\Yielder;\n\n$data = [\n    function () {\n        return 'Value 1';\n    },\n    function () {\n        return 'Value 2';\n    },\n    function () {\n        return 'Value 3';\n    },\n];\n\nYielder::eachCall($data, function ($value, $index) {\n    echo \"Index $index: $value\\n\";\n    // return true if you want to break.\n});\n```\n\n## 📖 License\n\nLicensed under the MIT license, see [LICENSE.md](LICENSE.md) for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnabeghe%2Fyielder-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnabeghe%2Fyielder-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnabeghe%2Fyielder-php/lists"}