{"id":15739988,"url":"https://github.com/ace411/ext-func","last_synced_at":"2025-10-04T02:06:11.304Z","repository":{"id":112032963,"uuid":"162718600","full_name":"ace411/ext-func","owner":"ace411","description":"A simple PHP extension with additional userland helper functions.","archived":false,"fork":false,"pushed_at":"2018-12-29T09:54:26.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T04:47:27.227Z","etag":null,"topics":["ext-func","functional-programming","helper-functions","php-cpp","php-extension"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ace411.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2018-12-21T13:40:49.000Z","updated_at":"2019-11-20T20:58:51.000Z","dependencies_parsed_at":"2023-07-31T04:02:10.480Z","dependency_job_id":null,"html_url":"https://github.com/ace411/ext-func","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"19cebe4f847eaf298583f60e2d703df8ecd7841d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ace411/ext-func","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ace411%2Fext-func","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ace411%2Fext-func/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ace411%2Fext-func/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ace411%2Fext-func/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ace411","download_url":"https://codeload.github.com/ace411/ext-func/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ace411%2Fext-func/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278254466,"owners_count":25956604,"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","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ext-func","functional-programming","helper-functions","php-cpp","php-extension"],"created_at":"2024-10-04T02:10:28.139Z","updated_at":"2025-10-04T02:06:11.280Z","avatar_url":"https://github.com/ace411.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ext-func\n\nA simple PHP extension written in C++ - with [PHP-CPP](http://php-cpp.com) - with additional userland helper functions.\n\n## Requirements\n\n- C++ 11\n- PHP-CPP extension\n- PHP 7 (or greater)\n\n## Installation\n\nBecause ext-func is an extension built on top of PHP-CPP, installation of PHP-CPP is a mandatory prerequisite for using this tool. There exists an elaborate [installation guide](http://www.php-cpp.com/documentation/install) on the PHP-CPP website - I suggest that you peruse it.\n\nOnce PHP-CPP is successfully installed on your system, type the following in a console to install ext-func on your machine.\n\n```\ngit clone https://github.com/ace411/ext-func.git\ncd ext-func\nmake \u0026\u0026 sudo make install\n```\n\n## Functions\n\nBecause the functions in this package are probably better suited for the PHP-userland, I'd recommend usage of libraries like [bingo-functional](https://github.com/ace411/bingo-functional) from which the package borrows multiple ideas, [functional-php](https://github.com/lstrojny/functional-php), or even [phunkie](https://github.com/phunkie/phunkie) or [lodash-php](https://github.com/lodash-php/lodash-php).\n\n### identity\n\nReturns the value received with no transformations.\n\n```php\n$identity = identity(12);\n//outputs 12\n```\n\n### map\n\nTransforms each entry in a collection.\n\n```php\n$map = map(function (int $val) : double {\n    return (double) ($val * 4) / 2;\n}, range(1, 4));\n//outputs [2, 4, 6, 8]\n```\n\n### mapDeep\n\nTransforms all list entries in a multi-dimensional array.\n\n```php\n$map = mapDeep(function ($val) : int {\n    return pow($val, 2);\n}, [2, 5, 7, 11, [3, 6, 9]]);\n//outputs [4, 25, 49, 121, [9, 36, 81]]\n```\n\n### filter\n\nSelect values based on a boolean predicate.\n\n```php\n$filter = filter(function (int $val) : bool {\n    return pow($val, 2) \u003e 36;\n}, range(4, 9));\n//outputs [7, 8, 9]\n```\n\n### filterDeep\n\nPerforms the filter action on a multi-dimensional array.\n\n```php\n$filter = filterDeep(function ($val) {\n    return mb_strlen($val, 'utf-8') \u003e 3;\n}, array('foo', array('bar', 'baz'), array('foo-bar')));\n//outputs [['foo-bar']]\n```\n\n### reject\n\nSelects values that do not conform to a boolean predicate.\n\n```php\n$list = A\\reject(function (int $val) : bool { \n    return $val % 2 == 0; \n}, array(12, 13, 19, 15, 22));\n//outputs [13, 19, 15]\n```\n\n### fold\n\nTransforms a list into a single value.\n\n```php\nconst LIST = array(4, 5, 7, 3);\n\n$fold = fold(function (int $acc, int $val) : int {\n    return $val \u003e $acc ? $val : $acc;\n}, LIST, reset(LIST));\n//outputs 7\n```\n\n### any\n\nChecks if a single value in a list conforms to a boolean predicate.\n\n```php\n$check = any(function ($val) : bool {\n    return is_bool($val);\n}, array(false, 'mike', 12));\n//outputs true\n```\n\n### every\n\nChecks if a boolean predicate holds for every value in a list.\n\n```php\n$check = every(function (int $val) : bool {\n    return is_int($val);\n}, range(5, 12));\n//outputs true\n```\n\n### flatten\n\nTruncates array dimensionality.\n\n```php\n$flat = flatten(array(4, 6, array(9, 84), array(12, 15)));\n//outputs [4, 6, 9, 84, 12, 15]\n```\n\n### keysExist\n\nChecks if specified keys exist in an array.\n\n```php\n$check = keysExist(\n    array(\n        'username' =\u003e 'ace411',\n        'packages' =\u003e array('bingo-functional', 'extfunc_cpp')\n    ),\n    array('password', 'twitter')\n);\n//outputs false\n```\n\n### mean\n\nComputes the mean of the numbers in an array.\n\n```php\n$avg = mean(range(12, 35));\n//outputs 23.5\n```\n\n### purge\n\nEliminates all the falsey values from an array.\n\n```php\n$purged = purge(array(false, null, 'rainbow', 12));\n//outputs ['rainbow', 12]\n```\n\n### head\n\nOutputs the first value in a list.\n\n```php\n$first = head(array('foo', 'bar'));\n//outputs 'foo'\n```\n\n### indexOf\n\nOutputs the key that corresponds with a value in a list.\n\n```php\nconst LIST = array(\n    'name' =\u003e 'mike',\n    'isWriter' =\u003e true\n);\n$index = indexOf('mike');\n//outputs 'name'\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Face411%2Fext-func","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Face411%2Fext-func","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Face411%2Fext-func/lists"}