{"id":17061850,"url":"https://github.com/phlak/splat","last_synced_at":"2025-09-13T01:48:15.195Z","repository":{"id":42463707,"uuid":"260334304","full_name":"PHLAK/Splat","owner":"PHLAK","description":"Glob-like file and pattern matching utility.","archived":false,"fork":false,"pushed_at":"2023-07-01T00:05:32.000Z","size":100,"stargazers_count":108,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-02T06:00:57.990Z","etag":null,"topics":["file-matching","glob","pattern-matching","php","regex","regular-expression"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/phlak/splat","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/PHLAK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"PHLAK","patreon":"PHLAK","custom":"https://paypal.me/ChrisKankiewicz"}},"created_at":"2020-04-30T22:46:24.000Z","updated_at":"2024-06-18T19:56:18.876Z","dependencies_parsed_at":"2024-06-18T20:12:53.731Z","dependency_job_id":null,"html_url":"https://github.com/PHLAK/Splat","commit_stats":{"total_commits":59,"total_committers":6,"mean_commits":9.833333333333334,"dds":"0.10169491525423724","last_synced_commit":"98a300fa41102ed59e72d25a9bf3941d597513f9"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHLAK%2FSplat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHLAK%2FSplat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHLAK%2FSplat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHLAK%2FSplat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PHLAK","download_url":"https://codeload.github.com/PHLAK/Splat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557767,"owners_count":20958047,"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":["file-matching","glob","pattern-matching","php","regex","regular-expression"],"created_at":"2024-10-14T10:48:24.814Z","updated_at":"2025-04-06T22:11:45.857Z","avatar_url":"https://github.com/PHLAK.png","language":"PHP","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"splat.svg\" alt=\"Splat\" width=\"50%\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/PHLAK/Splat/discussions\"\u003e\u003cimg src=\"https://img.shields.io/badge/Join_the-Community-7b16ff.svg?style=for-the-badge\" alt=\"Join our Community\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/users/PHLAK/sponsorship\"\u003e\u003cimg src=\"https://img.shields.io/badge/Become_a-Sponsor-cc4195.svg?style=for-the-badge\" alt=\"Become a Sponsor\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://paypal.me/ChrisKankiewicz\"\u003e\u003cimg src=\"https://img.shields.io/badge/Make_a-Donation-006bb6.svg?style=for-the-badge\" alt=\"One-time Donation\"\u003e\u003c/a\u003e\n    \u003cbr\u003e\n    \u003ca href=\"https://packagist.org/packages/PHLAK/Splat\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/PHLAK/Splat.svg?style=flat-square\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/PHLAK/Splat\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/PHLAK/Splat.svg?style=flat-square\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/PHLAK/Splat/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/PHLAK/Splat?style=flat-square\" alt=\"License\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/PHLAK/Splat/actions\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/PHLAK/Splat/test-suite.yaml?style=flat-square\u0026label=tests\" alt=\"Tests Status\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\nGlob-like file and pattern matching utility.\n\nRequirements\n------------\n\n  - [PHP](https://www.php.net/) \u003e= 8.1\n\nInstallation\n------------\n\nInstall Splat with Composer.\n\n    composer require phlak/splat\n\nThen import the `Glob` or `Pattern` classes as needed.\n\n```php\nuse PHLAK\\Splat\\Glob;\nuse PHLAK\\Splat\\Pattern;\n```\n\nPatterns\n--------\n\n`Glob` methods accept a `$pattern` as the first parameter. This can be a string\nor an instance of `\\PHLAK\\Splat\\Pattern`.\n\n```php\n$pattern = new Pattern(...);\n$pattern = Pattern::make(...);\n```\n\nA pattern string may contain one or more of the following special matching\nexpressions.\n\n### Matching Expressions\n\n  - `?` matches any single character\n  - `*` matches zero or more characters excluding `/` (`\\` on Windows)\n  - `**` matches zero or more characters including `/` (`\\` on Windows)\n  - `[abc]` matches a single character from the set (i.e. `a`, `b` or `c`)\n  - `[a-c]` matches a single character in the range (i.e. `a`, `b` or `c`)\n  - `[!abc]` matches any character not in the set (i.e. not `a`, `b` or `c`)\n  - `[!a-c]` matches any character not in the range (i.e. not `a`, `b` or `c`)\n  - `{foo,bar,baz}` matches any pattern in the set (i.e. `foo`, `bar` or `baz`)\n    - Sets may contain other matching patterns (i.e. `{foo,ba[rz]}`)\n\n### Assertions\n\nThe following assertions can be use to assert that a string is followed by, or\nnot followed by, another pattern.\n\n  - `(=foo)` matches any string that also contains `foo`\n  - `(!foo)` matches any string that does not also contain `foo`\n\nFor example, a pattern of `*.tar(!.{gz,xz})` will match a string ending with\n`.tar` or `.tar.bz` but not `tar.gz` or `tar.xz`.\n\n### Converting Patterns To Regular Expressions\n\nGlob patterns can be converted to a regular expression pattern.\n\n```php\nPattern::make('foo')-\u003etoRegex(); // Returns '#^foo$#'\nPattern::make('foo/bar.txt')-\u003etoRegex(); // Returns '#^foo/bar\\.txt$#'\nPattern::make('file.{yml,yaml}')-\u003etoRegex(); // Returns '#^file\\.(yml|yaml)$#'\n```\n\nYou can control regular expression line anchors via the `$anchors` parameter.\n\n```php\nuse PHLAK\\Splat\\Anchors;\nuse PHLAK\\Splat\\Pattern;\n\nPattern::make('foo')-\u003etoRegex(Anchors::NONE); // Returns '#foo#'\nPattern::make('foo')-\u003etoRegex(Anchors::START); // Returns '#^foo#'\nPattern::make('foo')-\u003etoRegex(Anchors::END); // Returns '#foo$#'\nPattern::make('foo')-\u003etoRegex(Anchors::BOTH); // Returns '#^foo$#'\n```\n\n### Pattern Character Escaping\n\nSometimes you may have characters in a string that shouldn't be treated as\nmatching expression characters. In those situations you can escape any character\nby preceeding it with a backslash (`\\`).\n\n```php\nPattern::make('What is happening\\?');\nPattern::make('Wall-E \\[2008\\].mp4');\n```\n\nYou may also escape glob pattern characters from a string programmatically with\nthe `Pattern::escape()` method.\n\n```php\nPattern::escape('What is happening?'); // Returns 'What is happening\\?'\nPattern::escape('*.{yml,yaml}'); // Returns '\\*.\\{yml\\,yaml\\}'\nPattern::escape('[Ss]pl*t.txt'); // Returns '\\[Ss\\]pl\\*t.txt'\n```\n\nMethods\n-------\n\n### Files In\n\nGet a list of files in a directory matching a glob pattern.\n\n```php\nGlob::in('**.txt', 'some/file/path');\n```\n\nReturns a [Symfony Finder Component](https://symfony.com/doc/current/components/finder.html)\ncontaining the files matching the glob pattern within the specified directory \n(e.g. `foo.txt`, `foo/bar.txt`, `foo/bar/baz.txt`, etc.).\n\n---\n\n### Exact Match\n\nTest if a string matches a glob pattern.\n\n```php\nGlob::match('*.txt', 'foo.txt'); // true\nGlob::match('*.txt', 'foo.log'); // false\n```\n\n---\n\n### Match Start\n\nTest if a string starts with a glob pattern.\n\n```php\nGlob::matchStart('foo/*', 'foo/bar.txt'); // true\nGlob::matchStart('foo/*', 'bar/foo.txt'); // false\n```\n\n---\n\n### Match End\n\nTest if a string ends with a glob pattern.\n\n```php\nGlob::matchEnd('**.txt', 'foo/bar.txt'); // true\nGlob::matchEnd('**.txt', 'foo/bar.log'); // false\n```\n\n---\n\n### Match Within\n\nTest if a string contains a glob pattern.\n\n```php\nGlob::matchWithin('bar', 'foo/bar/baz.txt'); // true\nGlob::matchWithin('bar', 'foo/baz/qux.txt'); // false\n```\n\n---\n\n### Filter an Array (of Strings)\n\nFilter an array of strings to values matching a glob pattern.\n\n```php\nGlob::filter('**.txt', [\n    'foo', 'foo.txt', 'bar.zip', 'foo/bar.png', 'foo/bar.txt',\n]);\n\n// Returns ['foo.txt', 'foo/bar.txt']\n```\n\n---\n\n### Reject an Array (of Strings)\n\nFilter an array of strings to values *not* matching a glob pattern.\n\n```php\nGlob::reject('**.txt', [\n    'foo', 'foo.txt', 'bar.zip', 'foo/bar.png', 'foo/bar.txt',\n]);\n\n// Returns ['foo', 'bar.zip', 'foo/bar.png']\n```\n\n\nChangelog\n---------\n\nA list of changes can be found on the [GitHub Releases](https://github.com/PHLAK/Splat/releases) page.\n\nTroubleshooting\n---------------\n\nFor general help and support join our [GitHub Discussion](https://github.com/PHLAK/Splat/discussions) or reach out on [Bluesky](https://bsky.app/profile/phlak.dev).\n\nPlease report bugs to the [GitHub Issue Tracker](https://github.com/PHLAK/Splat/issues).\n\nCopyright\n---------\n\nThis project is licensed under the [MIT License](https://github.com/PHLAK/Splat/blob/master/LICENSE).\n","funding_links":["https://github.com/sponsors/PHLAK","https://patreon.com/PHLAK","https://paypal.me/ChrisKankiewicz"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphlak%2Fsplat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphlak%2Fsplat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphlak%2Fsplat/lists"}