{"id":15296223,"url":"https://github.com/yuhanz/ramda-php","last_synced_at":"2025-04-13T19:41:12.538Z","repository":{"id":57088448,"uuid":"53478486","full_name":"yuhanz/ramda-php","owner":"yuhanz","description":"A PHP implementation of functional programming library equivalent to ramda.js.","archived":false,"fork":false,"pushed_at":"2017-09-04T17:26:28.000Z","size":57,"stargazers_count":19,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T10:21:23.260Z","etag":null,"topics":["functional-programming","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/yuhanz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-09T07:49:08.000Z","updated_at":"2023-07-06T10:07:29.000Z","dependencies_parsed_at":"2022-08-20T16:00:32.671Z","dependency_job_id":null,"html_url":"https://github.com/yuhanz/ramda-php","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/yuhanz%2Framda-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuhanz%2Framda-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuhanz%2Framda-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuhanz%2Framda-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuhanz","download_url":"https://codeload.github.com/yuhanz/ramda-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248770349,"owners_count":21158958,"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","php"],"created_at":"2024-09-30T18:09:47.118Z","updated_at":"2025-04-13T19:41:12.512Z","avatar_url":"https://github.com/yuhanz.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ramda-php\n\nThis is a PHP implementation of ramda.js - a functional programming library. (http://ramdajs.com/)\n\nSo far only the curry functions and part of the functions implemented. The library is capable of doing the what's in the ramda.js examples.\n\n### Implemented Methods\n\n- [x] add\n- [ ] addIndex\n- [x] adjust\n- [x] all\n- [ ] allPass\n- [ ] allUniq\n- [x] always\n- [x] and\n- [x] any\n- [x] anyPass\n- [x] ap\n- [ ] aperture\n- [x] append\n- [x] apply\n- [ ] applySpec\n- [x] assoc\n- [ ] assocPath\n- [ ] binary\n- [ ] bind\n- [x] both\n- [ ] call\n- [x] chain\n- [ ] clamp\n- [ ] clone\n- [x] comparator\n- [ ] complement\n- [x] compose\n- [ ] composeK\n- [ ] composeP\n- [x] concat\n- [x] cond\n- [ ] construct\n- [ ] constructN\n- [x] contains\n- [ ] converge\n- [ ] countBy\n- [x] curry\n- [x] curryN\n- [x] dec\n- [x] defaultTo\n- [ ] difference\n- [ ] differenceWith\n- [ ] dissoc\n- [ ] dissocPath\n- [x] divide\n- [ ] drop\n- [ ] dropLast\n- [ ] dropLastWhile\n- [ ] dropRepeats\n- [ ] dropRepeatsWith\n- [ ] dropWhile\n- [x] either\n- [ ] empty\n- [ ] eqBy\n- [ ] eqProps\n- [x] equals\n- [ ] evolve\n- [x] filter\n- [ ] find\n- [ ] findIndex\n- [ ] findLast\n- [ ] findLastIndex\n- [x] flatten\n- [ ] flip\n- [x] forEach\n- [ ] fromPairs\n- [x] groupBy\n- [x] gt\n- [x] gte\n- [x] has\n- [ ] hasIn\n- [x] head\n- [x] identical\n- [x] identity\n- [ ] ifElse\n- [x] inc\n- [ ] indexBy\n- [x] indexOf\n- [x] init\n- [ ] insert\n- [ ] insertAll\n- [ ] internal\n- [ ] intersection\n- [ ] intersectionWith\n- [ ] intersperse\n- [ ] into\n- [ ] invert\n- [ ] invertObj\n- [ ] invoker\n- [ ] is\n- [ ] isArrayLike\n- [ ] isEmpty\n- [ ] isNil\n- [x] join\n- [ ] juxt\n- [x] keys\n- [ ] keysIn\n- [x] last\n- [ ] lastIndexOf\n- [ ] length\n- [ ] lens\n- [ ] lensIndex\n- [ ] lensPath\n- [ ] lensProp\n- [ ] lift\n- [ ] liftN\n- [x] lt\n- [x] lte\n- [x] map\n- [ ] mapAccum\n- [ ] mapAccumRight\n- [ ] mapObjIndexed\n- [ ] match\n- [ ] mathMod\n- [x] max\n- [ ] maxBy\n- [ ] mean\n- [ ] median\n- [ ] memoize\n- [ ] merge\n- [ ] mergeAll\n- [ ] mergeWith\n- [ ] mergeWithKey\n- [x] min\n- [ ] minBy\n- [x] modulo\n- [ ] multiply\n- [ ] nAry\n- [x] negate\n- [ ] none\n- [x] not\n- [x] nth\n- [ ] nthArg\n- [ ] objOf\n- [x] of\n- [ ] omit\n- [x] once\n- [x] or\n- [ ] over\n- [x] pair\n- [ ] partial\n- [ ] partialRight\n- [x] partition\n- [ ] path\n- [ ] pathEq\n- [ ] pathOr\n- [ ] pathSatisfies\n- [x] pick\n- [x] pickAll\n- [ ] pickBy\n- [x] pipe\n- [ ] pipeK\n- [ ] pipeP\n- [ ] pluck\n- [x] prepend\n- [ ] product\n- [x] project\n- [x] prop\n- [x] propEq\n- [ ] propIs\n- [x] propOr\n- [x] propSatisfies\n- [ ] props\n- [x] range\n- [x] reduce\n- [ ] reduceBy\n- [ ] reduceRight\n- [ ] reduced\n- [x] reject\n- [x] remove\n- [ ] repeat\n- [ ] replace\n- [x] reverse\n- [ ] scan\n- [ ] sequence\n- [ ] set\n- [x] slice\n- [x] sort\n- [x] sortBy\n- [ ] split\n- [ ] splitAt\n- [ ] splitEvery\n- [ ] splitWhen\n- [x] subtract\n- [x] sum\n- [ ] symmetricDifference\n- [ ] symmetricDifferenceWith\n- [x] tail\n- [x] take\n- [ ] takeLast\n- [ ] takeLastWhile\n- [ ] takeWhile\n- [x] tap\n- [x] test\n- [x] times\n- [x] toLower\n- [ ] toPairs\n- [ ] toPairsIn\n- [ ] toString\n- [x] toUpper\n- [ ] transduce\n- [ ] transpose\n- [ ] traverse\n- [ ] trim\n- [ ] tryCatch\n- [ ] type\n- [ ] unapply\n- [ ] unary\n- [ ] uncurryN\n- [ ] unfold\n- [ ] union\n- [ ] unionWith\n- [ ] uniq\n- [ ] uniqBy\n- [ ] uniqWith\n- [ ] unless\n- [ ] unnest\n- [ ] update\n- [x] useWith\n- [x] values\n- [ ] valuesIn\n- [ ] view\n- [ ] when\n- [x] where\n- [x] whereEq\n- [ ] without\n- [ ] wrap\n- [x] xprod\n- [x] zip\n- [ ] zipObj\n- [ ] zipWith\n\n### Introduced Methods\nR::$flatten1 - flatten in non-recursive way (for 1 depth only).\n\n### How to Use\n\nCompose functions:\n\n```\n  require_once 'ramda.php';\n  \n  $getIncompleteTaskSummaries = function($membername) {\n    return (R::$compose)(\n      (R::$sortBy)((R::$prop)('dueDate')),\n      (R::$map)((R::$pick)(['id', 'dueDate', 'title', 'priority'])),\n      (R::$reject)((R::$propEq)('complete', true)),\n      (R::$filter)((R::$propEq)('username', $membername)),\n      (R::$prop)('tasks'));\n  };\n\n```\n\nUse the function on data:\n```\n  $data = [\n      'result' =\u003e \"SUCCESS\",\n      'interfaceVersion' =\u003e \"1.0.3\",\n      'requested' =\u003e \"10/17/2013 15:31:20\",\n      'lastUpdated' =\u003e \"10/16/2013 10:52:39\",\n      'tasks' =\u003e [\n          ['id' =\u003e 104, 'complete' =\u003e false,            'priority' =\u003e \"high\",\n                    'dueDate' =\u003e \"2013-11-29\",      'username' =\u003e \"Scott\",\n                    'title' =\u003e \"Do something\",      'created' =\u003e \"9/22/2013\"],\n          ['id' =\u003e 105, 'complete' =\u003e false,            'priority' =\u003e \"medium\",\n                    'dueDate' =\u003e \"2013-11-22\",      'username' =\u003e \"Lena\",\n                    'title' =\u003e \"Do something else\", 'created' =\u003e \"9/22/2013\"],\n          ['id' =\u003e 107, 'complete' =\u003e false,             'priority' =\u003e \"high\",\n                    'dueDate' =\u003e \"2013-11-22\",      'username' =\u003e \"Mike\",\n                    'title' =\u003e \"Fix the foo\",       'created' =\u003e \"9/22/2013\"],\n          ['id' =\u003e 108, 'complete' =\u003e false,            'priority' =\u003e \"low\",\n                    'dueDate' =\u003e \"2013-11-15\",      'username' =\u003e \"Punam\",\n                    'title' =\u003e \"Adjust the bar\",    'created' =\u003e \"9/25/2013\"],\n          ['id' =\u003e 110, 'complete' =\u003e false,            'priority' =\u003e \"medium\",\n                    'dueDate' =\u003e \"2013-11-15\",      'username' =\u003e \"Scott\",\n                    'title' =\u003e \"Rename everything\", 'created' =\u003e \"10/2/2013\"],\n          ['id' =\u003e 112, 'complete' =\u003e true,             'priority' =\u003e \"high\",\n                    'dueDate' =\u003e \"2013-11-27\",      'username' =\u003e \"Lena\",\n                    'title' =\u003e \"Alter all quuxes\",  'created' =\u003e \"10/5/2013\"],\n          ['id' =\u003e 122, 'complete' =\u003e false,             'priority' =\u003e \"high\",\n                    'dueDate' =\u003e \"2013-11-01\",      'username' =\u003e \"Mike\",\n                    'title' =\u003e \"Fix the bar\",       'created' =\u003e \"9/22/2013\"],\n          ['id' =\u003e 123, 'complete' =\u003e true,             'priority' =\u003e \"high\",\n                    'dueDate' =\u003e \"2013-11-22\",      'username' =\u003e \"Mike\",\n                    'title' =\u003e \"Fix the foobar\",       'created' =\u003e \"9/22/2013\"],\n\n      ]\n  ];\n  $tasks = $getIncompleteTaskSummaries(\"Mike\")($data);\n  print_r($tasks);\n```\n\nOutputs:\n\n```\n(\n    [0] =\u003e Array\n        (\n            [id] =\u003e 122\n            [dueDate] =\u003e 2013-11-01\n            [title] =\u003e Fix the bar\n            [priority] =\u003e high\n        )\n\n    [1] =\u003e Array\n        (\n            [id] =\u003e 107\n            [dueDate] =\u003e 2013-11-22\n            [title] =\u003e Fix the foo\n            [priority] =\u003e high\n        )\n\n)\n```\n\nNote: as a defect of PHP compiler, static method ```R::$add(1,2)``` wouldn't compile. To get around, place the static method inside parenthesis ```(R::$add)(1,2)```\n\nCurry functions:\n\n(Note: ```R::$_``` is the placeholder parameter.)\n\n```\n  $f3 = function($a, $b, $c) {\n      return $a*2+$b*3+$c*4;\n  };\n  $c = R::curry($f3);\n  $cc = $c(R::$_,2,R::$_);\n  print_r($cc(1,3));\n```\nOutputs:\n\n```\n  20\n```\n\n(More examples can be found in the /tests folder.)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuhanz%2Framda-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuhanz%2Framda-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuhanz%2Framda-php/lists"}