{"id":24016316,"url":"https://github.com/decodelabs/fluidity","last_synced_at":"2025-04-15T14:07:18.197Z","repository":{"id":43292109,"uuid":"301678781","full_name":"decodelabs/fluidity","owner":"decodelabs","description":"Tools for creating fluent interfaces in PHP","archived":false,"fork":false,"pushed_at":"2025-04-14T08:47:18.000Z","size":56,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-04-15T14:07:04.234Z","etag":null,"topics":["fluid-interface","php"],"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/decodelabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2020-10-06T09:38:35.000Z","updated_at":"2025-04-14T08:47:22.000Z","dependencies_parsed_at":"2024-05-16T02:44:16.907Z","dependency_job_id":"143878e7-5f11-4bf4-8b60-bcd9225c5872","html_url":"https://github.com/decodelabs/fluidity","commit_stats":{"total_commits":63,"total_committers":2,"mean_commits":31.5,"dds":"0.19047619047619047","last_synced_commit":"5d6b1ba260d48a6ad12e6019a6a2b64adbfe3c00"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Ffluidity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Ffluidity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Ffluidity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Ffluidity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/decodelabs","download_url":"https://codeload.github.com/decodelabs/fluidity/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249085437,"owners_count":21210267,"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":["fluid-interface","php"],"created_at":"2025-01-08T08:48:55.967Z","updated_at":"2025-04-15T14:07:18.189Z","avatar_url":"https://github.com/decodelabs.png","language":"PHP","readme":"# Fluidity\n\n[![PHP from Packagist](https://img.shields.io/packagist/php-v/decodelabs/fluidity?style=flat)](https://packagist.org/packages/decodelabs/fluidity)\n[![Latest Version](https://img.shields.io/packagist/v/decodelabs/fluidity.svg?style=flat)](https://packagist.org/packages/decodelabs/fluidity)\n[![Total Downloads](https://img.shields.io/packagist/dt/decodelabs/fluidity.svg?style=flat)](https://packagist.org/packages/decodelabs/fluidity)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/decodelabs/fluidity/integrate.yml?branch=develop)](https://github.com/decodelabs/fluidity/actions/workflows/integrate.yml)\n[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-44CC11.svg?longCache=true\u0026style=flat)](https://github.com/phpstan/phpstan)\n[![License](https://img.shields.io/packagist/l/decodelabs/fluidity?style=flat)](https://packagist.org/packages/decodelabs/fluidity)\n\n### Tools for creating fluent interfaces.\n\nFluidity provides a set of middleware interfaces that aid in the development of libraries that themselves aim to provide fluid interfaces.\n\n---\n\n## Installation\n\nInstall via Composer:\n\n```bash\ncomposer require decodelabs/fluidity\n```\n\n## Usage\n\n### Method chaining\n\n```php\nnamespace DecodeLabs\\Fluidity;\n\ninterface Then\n{\n    public function then(callable $callback): Then;\n    public function thenEach(iterable $values, callable $callback): Then;\n    public function thenIf(?bool $truth, callable $yes, callable $no=null): Then;\n    public function thenUnless(?bool $truth, callable $no, callable $yes=null): Then;\n}\n```\n\nCreate fluent object interfaces with basic generic logic structure support.\n\n```php\nuse DecodeLabs\\Fluidity\\Then;\nuse DecodeLabs\\Fluidity\\ThenTrait;\n\n$test = new class() implements Then {\n    use ThenTrait;\n\n    public function doThing(int $value=null) {}\n};\n\n$truth = true;\n\n$test\n    -\u003ethen(function($test) {\n        $test-\u003edoThing();\n    })\n\n    -\u003ethenEach([1, 2, 3], function($test, $value) {\n        // Called three times\n        $test-\u003edoThing($value);\n    })\n\n    -\u003ethenIf($truth, function($test) {\n        // This gets called if($truth)\n    }, function($test) {\n        // This get called otherwise\n    })\n\n    -\u003ethenUnless($truth, function($test) {\n        // This gets called if(!$truth)\n    }, function($test) {\n        // This get called otherwise\n    });\n```\n\n\n## Licensing\n\nFluidity is licensed under the MIT License. See [LICENSE](./LICENSE) for the full license text.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecodelabs%2Ffluidity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdecodelabs%2Ffluidity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecodelabs%2Ffluidity/lists"}