{"id":24613015,"url":"https://github.com/loophp/fpt","last_synced_at":"2025-10-06T06:30:31.610Z","repository":{"id":37010265,"uuid":"344064080","full_name":"loophp/fpt","owner":"loophp","description":"Functional programming toolbox for PHP.","archived":false,"fork":false,"pushed_at":"2024-05-06T12:20:03.000Z","size":103,"stargazers_count":25,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-06T14:09:04.145Z","etag":null,"topics":["functional-programming","toolbox"],"latest_commit_sha":null,"homepage":"https://loophp-fpt.rtfd.io/","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/loophp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","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":"drupol","custom":["https://www.paypal.me/drupol"]}},"created_at":"2021-03-03T09:03:26.000Z","updated_at":"2024-05-06T14:09:05.112Z","dependencies_parsed_at":"2024-04-24T14:44:34.627Z","dependency_job_id":null,"html_url":"https://github.com/loophp/fpt","commit_stats":{"total_commits":52,"total_committers":2,"mean_commits":26.0,"dds":0.4423076923076923,"last_synced_commit":"c6240b446d17729377c8d58598b095155d559c10"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loophp%2Ffpt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loophp%2Ffpt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loophp%2Ffpt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loophp%2Ffpt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loophp","download_url":"https://codeload.github.com/loophp/fpt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235503989,"owners_count":19000703,"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":["functional-programming","toolbox"],"created_at":"2025-01-24T20:39:30.343Z","updated_at":"2025-10-06T06:30:26.322Z","avatar_url":"https://github.com/loophp.png","language":"PHP","funding_links":["https://github.com/sponsors/drupol","https://www.paypal.me/drupol"],"categories":[],"sub_categories":[],"readme":"[![Latest Stable Version][latest stable version]][packagist fpt]\n [![GitHub stars][github stars]][packagist fpt]\n [![Total Downloads][total downloads]][packagist fpt]\n [![GitHub Workflow Status][github workflow status]][fpt actions]\n [![Scrutinizer code quality][code quality]][scrutinizer code quality]\n [![Type Coverage][type coverage]][sheperd type coverage]\n [![Code Coverage][code coverage]][scrutinizer code quality]\n [![License][license]][packagist fpt]\n [![Read the Docs][read the docs badge]][read the docs link]\n [![Donate!][donate github]][github sponsor]\n [![Donate!][donate paypal]][paypal sponsor]\n\n# Functional Programming Toolbox\n\n## Description\n\n**F**unctional **P**rogramming **T**oolbox (***FPT** for the friends*) is a set of\nstateless and immutable helper classes to facilitate the use of functional programming(*FP*) concepts.\n\nThis projects doesn't aim to transform PHP into a full featured FP language,\nbut it will helps users willing to use and understand a subset of FP concepts in\ntheir own code.\n\n## Requirements\n\n* PHP 8\n\n## Installation\n\n```shell\ncomposer require loophp/fpt\n```\n\n## Usage\n\n### Curry and Partial\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace Example;\n\ninclude __DIR__ . '/vendor/autoload.php';\n\nuse loophp\\fpt\\FPT;\n\n// The \"curry\" method combine at the same time the\n// Curry and Partial, see example below.\n$explode = FPT::curry()('explode');\n\n// Thanks to the new PHP 8 feature \"named arguments\",\n// you can pass arguments in any order.\n\nvar_dump($explode(',', 'a,b,c'));\nvar_dump($explode(separator: ',', string: 'a,b,c'));\nvar_dump($explode(separator: ',')(string: 'a,b,c'));\nvar_dump($explode(string: 'a,b,c', separator: ','));\nvar_dump($explode(string: 'a,b,c')(separator: ','));\n\n// All of these will return:\n/**\n * array(3) {\n *   [0] =\u003e string(1) \"a\"\n *   [1] =\u003e string(1) \"b\"\n *   [2] =\u003e string(1) \"c\"\n * }\n*/\n\n// You can pass an optional \"arity\" argument\n\n$explode = FPT::curry()('explode', 3);\n\nvar_dump($explode(',', 'a,b,c', 2));\nvar_dump($explode(separator: ',', string: 'a,b,c', limit: 2));\nvar_dump($explode(separator: ',')(string: 'a,b,c')(limit: 2));\nvar_dump($explode(limit: 2, string: 'a,b,c', separator: ','));\nvar_dump($explode(limit: 2)(string: 'a,b,c')(separator: ','));\n\n// All of these will return:\n/**\n * array(2) {\n *   [0] =\u003e string(1) \"a\"\n *   [1] =\u003e string(3) \"b,c\"\n * }\n*/\n```\n\n### Composition\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace Example;\n\ninclude __DIR__ . '/vendor/autoload.php';\n\nuse loophp\\fpt\\FPT;\n\n$closure = static fn (string $first, string $second): string =\u003e sprintf(\"My cats names are %s and %s.\", $first, $second);\n\n$composedClosure = FPT::compose()('strtoupper', $closure);\n\n$composedClosure('Izumi', 'Nakano'); // \"MY CATS NAMES ARE IZUMI AND NAKANO.\"\n```\n\n## Documentation\n\n[The API][fpt api] will give you a pretty good idea of the existing methods and what\nyou can do with it.\n\nI'm doing my best to keep the documentation up to date, if you found something odd,\nplease let me know in the [issue queue][fpt issue queue].\n\n## Code quality, tests and benchmarks\n\nEvery time changes are introduced into the library, [Github][fpt actions] run the\ntests.\n\nThe library has tests written with [PHPSpec][phpspec].\nFeel free to check them out in the `spec` directory. Run `composer phpspec` to trigger the tests.\n\nBefore each commit some inspections are executed with [GrumPHP][grumphp],\nrun `composer grumphp` to check manually.\n\nThe quality of the tests is tested with [Infection][infection] a PHP Mutation testing\nframework,  run `composer infection` to try it.\n\nStatic analysers are also controlling the code. [PHPStan][phpstan] and\n[PSalm][psalm] are enabled to their maximum level.\n\n## Contributing\n\nFeel free to contribute by sending Github pull requests. I'm quite reactive :-)\n\nIf you can't contribute to the code, you can also sponsor me on [Github][github sponsor] or [Paypal][paypal sponsor].\n\n## Changelog\n\nSee [CHANGELOG.md][changelog-md] for a changelog based on [git commits][git-commits].\n\nFor more detailed changelogs, please check [the release changelogs][changelog-releases].\n\n## Thanks\n\nThe API documentation has been inspired by the [Ramda][http ramda] project.\n\n[packagist fpt]: https://packagist.org/packages/loophp/fpt\n[latest stable version]: https://img.shields.io/packagist/v/loophp/fpt.svg?style=flat-square\n[github stars]: https://img.shields.io/github/stars/loophp/fpt.svg?style=flat-square\n[total downloads]: https://img.shields.io/packagist/dt/loophp/fpt.svg?style=flat-square\n[github workflow status]: https://img.shields.io/github/workflow/status/loophp/fpt/Unit%20tests?style=flat-square\n[code quality]: https://img.shields.io/scrutinizer/quality/g/loophp/fpt/master.svg?style=flat-square\n[scrutinizer code quality]: https://scrutinizer-ci.com/g/loophp/fpt/?branch=master\n[type coverage]: https://img.shields.io/badge/dynamic/json?style=flat-square\u0026color=color\u0026label=Type%20coverage\u0026query=message\u0026url=https%3A%2F%2Fshepherd.dev%2Fgithub%2Floophp%2Ffpt%2Fcoverage\n[sheperd type coverage]: https://shepherd.dev/github/loophp/fpt\n[code coverage]: https://img.shields.io/scrutinizer/coverage/g/loophp/fpt/master.svg?style=flat-square\n[license]: https://img.shields.io/packagist/l/loophp/fpt.svg?style=flat-square\n[read the docs badge]: https://img.shields.io/readthedocs/loophp-fpt?style=flat-square\n[read the docs link]: https://loophp-fpt.readthedocs.io/\n[donate github]: https://img.shields.io/badge/Sponsor-Github-brightgreen.svg?style=flat-square\n[donate paypal]: https://img.shields.io/badge/Sponsor-Paypal-brightgreen.svg?style=flat-square\n[fpt documentation site]: https://loophp-fpt.rtfd.io\n[fpt api]: https://loophp-fpt.readthedocs.io/en/latest/pages/api.html\n[fpt usage]: https://loophp-fpt.readthedocs.io/en/latest/pages/usage.html\n[fpt examples]: https://loophp-fpt.readthedocs.io/en/latest/pages/examples.html\n[fpt issue queue]: https://github.com/loophp/fpt/issues\n[fpt actions]: https://github.com/loophp/fpt/actions\n[phpspec]: http://www.phpspec.net/\n[grumphp]: https://github.com/phpro/grumphp\n[infection]: https://github.com/infection/infection\n[phpstan]: https://github.com/phpstan/phpstan\n[psalm]: https://github.com/vimeo/psalm\n[github sponsor]: https://github.com/sponsors/drupol\n[paypal sponsor]: https://www.paypal.me/drupol\n[changelog-md]: https://github.com/loophp/fpt/blob/master/CHANGELOG.md\n[git-commits]: https://github.com/loophp/fpt/commits/master\n[changelog-releases]: https://github.com/loophp/fpt/releases\n[http ramda]: https://ramdajs.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floophp%2Ffpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floophp%2Ffpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floophp%2Ffpt/lists"}