{"id":24738655,"url":"https://github.com/zweifisch/php-pattern-matching","last_synced_at":"2025-10-10T08:30:20.759Z","repository":{"id":9083668,"uuid":"10858458","full_name":"zweifisch/php-pattern-matching","owner":"zweifisch","description":"pattern matching for php","archived":false,"fork":false,"pushed_at":"2013-09-03T13:03:02.000Z","size":132,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-11T23:59:11.744Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"rebelidealist/stripe-ruby-mock","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zweifisch.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":"2013-06-22T03:56:46.000Z","updated_at":"2021-08-22T19:29:22.000Z","dependencies_parsed_at":"2022-09-16T12:41:11.694Z","dependency_job_id":null,"html_url":"https://github.com/zweifisch/php-pattern-matching","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/zweifisch/php-pattern-matching","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fphp-pattern-matching","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fphp-pattern-matching/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fphp-pattern-matching/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fphp-pattern-matching/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zweifisch","download_url":"https://codeload.github.com/zweifisch/php-pattern-matching/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fphp-pattern-matching/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003299,"owners_count":26083555,"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-10-10T02:00:06.843Z","response_time":62,"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":[],"created_at":"2025-01-27T22:55:16.936Z","updated_at":"2025-10-10T08:30:20.436Z","avatar_url":"https://github.com/zweifisch.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# match [![Build Status](https://travis-ci.org/zweifisch/php-pattern-matching.png?branch=master)](https://travis-ci.org/zweifisch/php-pattern-matching)\n\npattern matching for php\n\ninstall via composer\n\n```sh\ncomposer require 'zweifisch/match:*'\n```\n\ndestruct value\n\n```php\n$array = [1,[2,[3,4]]];\nextract(\\match\\destruct(['a',['b',['c','d']]], $array)) or die(\"match failed\");\necho \"$a $b $c $d\"; // \"1 2 3 4\"\n```\n\npassing to a function\n\n```php\n$input = ['method'=\u003e'foo', 'params'=\u003e['bar']];\n$pattern = ['method'=\u003e'func', 'params'=\u003e['arg1']];\n$result = \\match\\let($pattern, $input, function($arg1, $func){\n\treturn \"$func $arg1\";\n});\n// \"foo bar\"\n```\n\ndestruct multiple values\n\n```php\n$input = ['method'=\u003e'foo', 'params'=\u003e['bar']];\n$result = \\match\\let(\n\t['method'=\u003e'func', 'params'=\u003e['arg1']], $input\n\t'now', time(),\n\tfunction($func, $arg1, $now){\n\t\treturn \"$func $arg1 $now\";\n\t}\n);\n```\n\n## tests\n\n```sh\ncomposer install --dev\nvendor/bin/phpunit -c tests\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzweifisch%2Fphp-pattern-matching","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzweifisch%2Fphp-pattern-matching","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzweifisch%2Fphp-pattern-matching/lists"}