{"id":17437120,"url":"https://github.com/nabeghe/matcher-php","last_synced_at":"2026-02-02T19:31:11.865Z","repository":{"id":257822004,"uuid":"871267464","full_name":"nabeghe/matcher-php","owner":"nabeghe","description":"A similar alternative to match in PHP for arrays, with a touch of zest.","archived":false,"fork":false,"pushed_at":"2025-07-03T12:51:30.000Z","size":11,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-17T07:10:49.111Z","etag":null,"topics":["array","library","php","phplibrary"],"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-11T15:45:11.000Z","updated_at":"2025-07-03T12:50:33.000Z","dependencies_parsed_at":"2024-12-07T03:34:48.940Z","dependency_job_id":null,"html_url":"https://github.com/nabeghe/matcher-php","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"0790299d2117c8cf1dc490f242f70937add9f3e5"},"previous_names":["nabeghe/matcher-php"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/nabeghe/matcher-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeghe%2Fmatcher-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeghe%2Fmatcher-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeghe%2Fmatcher-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeghe%2Fmatcher-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nabeghe","download_url":"https://codeload.github.com/nabeghe/matcher-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeghe%2Fmatcher-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29017985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T18:51:31.335Z","status":"ssl_error","status_checked_at":"2026-02-02T18:49:20.777Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","library","php","phplibrary"],"created_at":"2024-10-17T11:05:51.486Z","updated_at":"2026-02-02T19:31:11.849Z","avatar_url":"https://github.com/nabeghe.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Matcher for PHP ≥ 7.4\n\n\u003e A similar alternative to match in PHP for arrays, with a touch of zest.\n\nExtracting values and keys from an array with some variations in functionality.\n\n## 🫡 Usage\n\n### 🚀 Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require nabeghe/matcher\n```\n\n### Example 1: Value\n\nSimilar to match in PHP 8.\n\n```php\nuse \\Nabeghe\\Matcher\\Matcher;\n\n$matched_value = Matcher::value([\n    'key1' =\u003e 'value 1',\n    'key2' =\u003e 'value 2',\n    'key3' =\u003e 'value 3',\n    'key4' =\u003e 'value 4',\n    'key5' =\u003e 'value 5',\n], 'key5');\n\necho $matched_value; // value 5\n```\n\n### Example 2: Default Value\n\nSimilar to match in PHP 8, with a default value in case the key doesn't exist.\n\n```php\nuse \\Nabeghe\\Matcher\\Matcher;\n\n$matched_value = Matcher::value([\n    'key1' =\u003e 'value 1',\n    'key2' =\u003e 'value 2',\n    'key3' =\u003e 'value 3',\n    'key4' =\u003e 'value 4',\n    'key5' =\u003e 'value 5',\n], 'key', 'value not found');\n\necho $matched_value; // value not found\n```\n\n### Example 3: Callable Value\n\nSimilar to match in PHP 8, with the possibility of the value being callable.\n\n```php\n$matched_value = Matcher::value([\n    'key1' =\u003e 'value 1',\n    'key2' =\u003e 'value 2',\n    'key3' =\u003e 'value 3',\n    'key4' =\u003e 'value 4',\n    'key5' =\u003e function ($key) {\n        return 'value 5';\n    },\n], 'key5', null, true);\n\necho $matched_value; // value 5\n```\n\n### Example 4: Key\n\nFinding a key based on a value.\n\n```php\nuse \\Nabeghe\\Matcher\\Matcher;\n\n$matched_value = Matcher::key([\n    'key1' =\u003e 'value 1',\n    'key2' =\u003e 'value 2',\n    'key3' =\u003e 'value 3',\n    'key4' =\u003e 'value 4',\n    'key5' =\u003e 'value 5',\n], 'value 5');\n\necho $matched_value; // key5\n```\n\n### Example 5: Keys By Value\n\nFinding a set of keys based on a specific value.\n\n```php\nuse \\Nabeghe\\Matcher\\Matcher;\n\n$matched_value = Matcher::keys([\n    'key1' =\u003e 'value 1',\n    'key2' =\u003e 'value 2',\n    'key3' =\u003e 'value 3',\n    'key4' =\u003e 'value 4',\n    'keys1' =\u003e 'value x',\n    'keys2' =\u003e 'value x',\n], 'value x');\n\nprint_r($matched_value); // keys1, keys2\n```\n\n### Example 6: Keys By Values\n\nFinding a set of keys based on a a set of values.\n\n```php\nuse \\Nabeghe\\Matcher\\Matcher;\n\n$matched_value = Matcher::keys([\n    'key1' =\u003e 'value 1',\n    'key2' =\u003e 'value 2',\n    'key3' =\u003e 'value 3',\n    'key4' =\u003e 'value 4',\n    'key5' =\u003e 'value 5',\n], ['value 1', 'value 5']);\n\nprint_r($matched_value); // key1, key5\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%2Fmatcher-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnabeghe%2Fmatcher-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnabeghe%2Fmatcher-php/lists"}