{"id":20833833,"url":"https://github.com/denissimon/formula-parser","last_synced_at":"2025-05-16T13:08:09.930Z","repository":{"id":23318408,"uuid":"26678311","full_name":"denissimon/formula-parser","owner":"denissimon","description":"Parsing and evaluating mathematical formulas given as strings.","archived":false,"fork":false,"pushed_at":"2024-11-14T07:44:18.000Z","size":47,"stargazers_count":80,"open_issues_count":0,"forks_count":24,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-12T10:57:54.245Z","etag":null,"topics":["composer","evaluation","expression","formula","math","parser","parsing","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/denissimon.png","metadata":{"files":{"readme":"README.md","changelog":"History.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":"2014-11-15T11:47:05.000Z","updated_at":"2025-03-04T10:29:07.000Z","dependencies_parsed_at":"2024-11-26T08:46:01.438Z","dependency_job_id":null,"html_url":"https://github.com/denissimon/formula-parser","commit_stats":{"total_commits":37,"total_committers":3,"mean_commits":"12.333333333333334","dds":0.08108108108108103,"last_synced_commit":"d6d19374f75f9a353fbbdb0945eb9dbbb602f8b2"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denissimon%2Fformula-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denissimon%2Fformula-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denissimon%2Fformula-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denissimon%2Fformula-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/denissimon","download_url":"https://codeload.github.com/denissimon/formula-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254131794,"owners_count":22020013,"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":["composer","evaluation","expression","formula","math","parser","parsing","php"],"created_at":"2024-11-18T00:16:57.990Z","updated_at":"2025-05-16T13:08:09.906Z","avatar_url":"https://github.com/denissimon.png","language":"PHP","readme":"Formula Parser\n==============\n\n[![Latest Stable Version](https://poser.pugx.org/denissimon/formula-parser/v/stable.svg)](https://packagist.org/packages/denissimon/formula-parser)\n[![Total Downloads](https://poser.pugx.org/denissimon/formula-parser/downloads)](https://packagist.org/packages/denissimon/formula-parser)\n[![License](https://poser.pugx.org/denissimon/formula-parser/license.svg)](https://github.com/denissimon/formula-parser/blob/master/LICENSE)\n\nFormula Parser is a library for parsing and evaluating mathematical formulas given as strings.\n\nSupports:\n\n* Operators: +, -, *, /, ^\n* Variables: x, y, z, a, b\n* Numbers with decimal point '.'\n* Numbers in E notation\n* Constants: pi, e, Inf\n* Functions: sqrt, abs, sin, cos, tan, log, exp\n* Unlimited nested parentheses\n* NaN (Not a Number)\n\nInstallation\n------------\n\nRequires [PHP 5.4 or higher](http://php.net).\n\nTo install with [Composer](https://getcomposer.org):\n\n``` sh\ncomposer require denissimon/formula-parser\n```\n\nUsage\n-----\n\n``` php\nrequire_once __DIR__ . '/vendor/autoload.php';\n\nuse FormulaParser\\FormulaParser;\n\n$formula = '3*x^2 - 4*y + 3/y';\n$precision = 2; // Number of digits after the decimal point\n\ntry {\n    $parser = new FormulaParser($formula, $precision);\n    $parser-\u003esetVariables(['x' =\u003e -4, 'y' =\u003e 8]);\n    $result = $parser-\u003egetResult(); // [0 =\u003e 'done', 1 =\u003e 16.38]\n} catch (\\Exception $e) {\n    echo $e-\u003egetMessage(), \"\\n\";\n}\n```\n\nThe `$precision` parameter has a default of 4, and it's not required to specify:\n\n``` php\n$parser = new FormulaParser('3+4*2/(1-5)^8');\n$result = $parser-\u003egetResult(); // [0 =\u003e 'done', 1 =\u003e 3.0001]\n```\n\nThe initialized object `$parser` has the following methods:\n\n`setValidVariables($array)` Overwrites default valid variables.\n\n`setVariables($array)` Sets variables.\n\n`getResult()` Returns an array [0 =\u003e v1, 1 =\u003e v2], where v1 is 'done' or 'error', and v2 is a computed result or validation error message, respectively.\n\n`getFormula()` Returns the text of the formula passed to the constructor.\n\nMore usage examples can be found in `tests/FormulaParserTest.php`\n\nLicense\n-------\n\nLicensed under the [MIT license](https://github.com/denissimon/formula-parser/blob/master/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenissimon%2Fformula-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenissimon%2Fformula-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenissimon%2Fformula-parser/lists"}