{"id":13828062,"url":"https://github.com/nunomaduro/curryable","last_synced_at":"2025-04-09T10:09:05.189Z","repository":{"id":57029370,"uuid":"240142338","full_name":"nunomaduro/curryable","owner":"nunomaduro","description":"An elegant and simple curry(f) implementation in PHP.","archived":false,"fork":false,"pushed_at":"2021-11-21T18:23:09.000Z","size":241,"stargazers_count":176,"open_issues_count":0,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-02T08:11:17.627Z","etag":null,"topics":["curry","functional-programming","laravel","php"],"latest_commit_sha":null,"homepage":"https://nunomaduro.com","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/nunomaduro.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"nunomaduro","patreon":"nunomaduro","custom":"https://www.paypal.com/paypalme/enunomaduro"}},"created_at":"2020-02-13T00:14:26.000Z","updated_at":"2024-09-09T22:30:19.000Z","dependencies_parsed_at":"2022-08-23T18:50:13.046Z","dependency_job_id":null,"html_url":"https://github.com/nunomaduro/curryable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nunomaduro%2Fcurryable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nunomaduro%2Fcurryable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nunomaduro%2Fcurryable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nunomaduro%2Fcurryable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nunomaduro","download_url":"https://codeload.github.com/nunomaduro/curryable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248018061,"owners_count":21034048,"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":["curry","functional-programming","laravel","php"],"created_at":"2024-08-04T09:02:30.573Z","updated_at":"2025-04-09T10:09:05.160Z","avatar_url":"https://github.com/nunomaduro.png","language":"PHP","funding_links":["https://github.com/sponsors/nunomaduro","https://patreon.com/nunomaduro","https://www.paypal.com/paypalme/enunomaduro","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=66BYDWAT92N6L","https://www.patreon.com/nunomaduro"],"categories":["PHP"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/nunomaduro/curryable/master/docs/example.png\" alt=\"Curryable\" height=\"300\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://travis-ci.org/nunomaduro/curryable\"\u003e\u003cimg src=\"https://img.shields.io/travis/nunomaduro/curryable/master.svg\" alt=\"Build Status\"\u003e\u003c/img\u003e\u003c/a\u003e\n  \u003ca href=\"https://packagist.org/packages/nunomaduro/curryable\"\u003e\u003cimg src=\"https://poser.pugx.org/nunomaduro/curryable/d/total.svg\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://packagist.org/packages/nunomaduro/curryable\"\u003e\u003cimg src=\"https://poser.pugx.org/nunomaduro/curryable/v/stable.svg\" alt=\"Latest Version\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://packagist.org/packages/nunomaduro/curryable\"\u003e\u003cimg src=\"https://poser.pugx.org/nunomaduro/curryable/license.svg\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## About Curryable\n\n**This package is under development, please don't use it on production and wait for the stable release!**\n\nCurryable was created by, and is maintained by [Nuno Maduro](https://github.com/nunomaduro), and is an elegant and simple\n**curry(f)** implementation in PHP. Currying is an advanced technique of working with functions. It **wraps the given expressions and arguments into a new function** that resolves a value.\n\n## Installation \u0026 Usage\n\n\u003e **Requires [PHP 7.2+](https://php.net/releases/)**\n\nCreate your package using [Composer](https://getcomposer.org):\n\n```bash\ncomposer require nunomaduro/curryable\n```\n\nThis helper usage is best described through example in the [Laravel](https://laravel.com) framework:\n\n### On routing\n\n```php\nRoute::get('/', curry('view', 'welcome'));\n\n// Instead of\nRoute::get('/', function () {\n    return view('welcome');\n});\n```\n\n```php\nRoute::get('user/{id}', curry(User::class)-\u003efind());\n// Or with Eloquent macro\nRoute::get('user/{id}', User::curry()-\u003efind());\n\n// Instead of\nRoute::get('user/{id}', function ($id) {\n    return User::find($id);\n});\n```\n\n### On macros\n\nRenaming the `lower` method to `toLower`:\n\n```php\nStr::macro('toLower', curry()-\u003elower());\n// or with the global `strtolower`\nStr::macro('toLower', curry('strtolower'));\n\n// Instead of\nStr::macro('toLower', function ($value) {\n    return Str::lower($value);\n});\n```\n\n### On collections\n\nUsing the global `strtoupper`:\n```php\n$collection = collect(['nuno'])-\u003emap(curry('strtoupper')); // ['NUNO']\n\n// Instead of\n$collection = collect(['nuno'])-\u003emap(function ($name) {\n    return strtoupper($name);\n});\n```\n\nHere is another example using the `each`:\n```php \n// Calls User::create($user) foreach user\ncollect($users)-\u003eeach(User::curry()-\u003ecreate());\n\n// Instead of\n$collection = collect($users)-\u003emap(function ($user) {\n    return User::create($user);\n});\n```\n\n### Dispatching jobs:\n```php\ndispatch(curry(Artisan::class)-\u003ecall('horizon:terminate'));\n\n// Instead of\ndispatch(function () {\n    Artisan::call('horizon:terminate');\n});\n```\n\n### Curry on class instance methods\n\nWith global helper:\n\n```php\n$closure = curry($instance)-\u003einstanceMethodName();\n$closure($first, $second);\n\n$closure = curry($instance)-\u003einstanceMethodName($first);\n$closure($second); // just need for the second argument\n\n$closure = curry($instance)-\u003einstanceMethodName($first, $second);\n$closure(); // no need for arguments\n```\n\nWith trait `NunoMaduro\\Curryable\\Curryable`:\n\n```php\n$closure = $instance-\u003ecurry()-\u003einstanceMethodName();\n$closure($first, $second);\n\n$closure = $instance-\u003ecurry()-\u003einstanceMethodName($first);\n$closure($second); // just need for the second argument\n\n$closure = $instance-\u003ecurry()-\u003einstanceMethodName($first, $second);\n$closure(); // no need for arguments\n```\n\n### Curry on class static methods\n\n```php\n// Curry on instance methods\n$closure = curry(Instance::class)-\u003estaticMethodName();\n$closure($first, $second);\n\n$closure = curry(Instance::class)-\u003estaticMethodName($first);\n$closure($second); // just need for the second argument\n\n$closure = curry(Instance::class)-\u003estaticMethodName($first, $second);\n$closure(); // no need for arguments\n```\n\n### Curry on functions\n\n```php\n// Curry on instance methods\n$closure = curry('function_name');\n$closure($first, $second);\n\n$closure = curry('function_name', $first);\n$closure($second); // just need for the second argument\n\n$closure = curry('function_name', $first, $second);\n$closure(); // no need for arguments\n```\n\n## Contributing\n\nThank you for considering to contribute to *Curryable*. All the contribution guidelines are mentioned [here](CONTRIBUTING.md).\n\nYou can have a look at the [CHANGELOG](CHANGELOG.md) for constant updates \u0026 detailed information about the changes. You can also follow the twitter account for latest announcements or just come say hi!: [@enunomaduro](https://twitter.com/enunomaduro)\n\n## Support the development\n**Do you like this project? Support it by donating**\n\n- Github sponsors: [Donate](https://github.com/sponsors/nunomaduro)\n- PayPal: [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=66BYDWAT92N6L)\n- Patreon: [Donate](https://www.patreon.com/nunomaduro)\n\n## License\n\ncurryable is an open-sourced software licensed under the [MIT license](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnunomaduro%2Fcurryable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnunomaduro%2Fcurryable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnunomaduro%2Fcurryable/lists"}