{"id":18470323,"url":"https://github.com/illegalstudio/fluent-bcmath","last_synced_at":"2025-04-08T11:31:41.351Z","repository":{"id":152470319,"uuid":"626004148","full_name":"illegalstudio/fluent-bcmath","owner":"illegalstudio","description":null,"archived":false,"fork":false,"pushed_at":"2024-01-17T16:08:54.000Z","size":30,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-19T05:07:21.666Z","etag":null,"topics":["bcmath","laravel","math","php","php-library"],"latest_commit_sha":null,"homepage":"https://fluent-bcmath.illegal.studio/","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/illegalstudio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.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}},"created_at":"2023-04-10T15:35:59.000Z","updated_at":"2023-04-21T08:20:11.000Z","dependencies_parsed_at":"2024-01-17T18:16:39.262Z","dependency_job_id":null,"html_url":"https://github.com/illegalstudio/fluent-bcmath","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/illegalstudio%2Ffluent-bcmath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/illegalstudio%2Ffluent-bcmath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/illegalstudio%2Ffluent-bcmath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/illegalstudio%2Ffluent-bcmath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/illegalstudio","download_url":"https://codeload.github.com/illegalstudio/fluent-bcmath/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223317875,"owners_count":17125605,"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":["bcmath","laravel","math","php","php-library"],"created_at":"2024-11-06T10:13:37.693Z","updated_at":"2024-11-06T10:13:38.338Z","avatar_url":"https://github.com/illegalstudio.png","language":"PHP","readme":"# fluent-bcmath\n\nFluent BcMath is a fluent interface for the PHP BcMath extension.\n\nIt helps you to write more readable code, while maintaining the performance of the BcMath extension.\n\n## Installation\n\nInstall the package via composer:\n\n```bash\ncomposer require \"illegal/fluent-bcmath\"\n```\n\n## Usage\n\nYou have two options to use the fluent interface.\n\nIn both cases, there are two arguments: the number and the scale.\nThe number can be:\n- a string\n- an integer\n- a float\n- another `BCNumber` instance\n\nThe scale is an integer, which represents the number of digits after the decimal point.\n\nAll methods return a new `BCNumber` instance, so you can chain them.\n\nFor example:\n\n```php\nuse Illegal\\FluentBCMath\\BCNumber;\n$num = new BCNumber('1.23', 2);\n\n$num-\u003eadd(2)-\u003esub(2)-\u003emul(2)-\u003ediv(2)-\u003emod(3)-\u003epow(2)-\u003esqrt();\n```\n\n### 1. Use the `BCNumber` class\n\n```php\nuse Illegal\\FluentBCMath\\BCNumber;\n\n$num = new BCNumber('1.23', 2); // 1st argument is the number, 2nd argument is the scale\n```\n\n### 2. Use the `fnum()` helper function\n\n```php\n$num = fnum('1.23', 2); // 1st argument is the number, 2nd argument is the scale\n```\n\n## Available methods\n\n```php\n$num = fnum(10, 2);\n\n$num-\u003eadd(2); // 12.00\n$num-\u003esub(2); // 8.00\n$num-\u003emul(2); // 20.00\n$num-\u003ediv(2); // 5.00\n$num-\u003emod(3); // 1.00\n$num-\u003epow(2); // 100.00\n$num-\u003esqrt(); // 3.16\n\n$num-\u003eequals(10); // true\n$num-\u003egreaterThan(5); // true\n$num-\u003egreaterThanOrEqual(10); // true\n$num-\u003elessThan(15); // true\n$num-\u003elessThanOrEqual(10); // true\n$num-\u003eisZero(); // false\n$num-\u003eisPositive(); // true\n$num-\u003eisNegative(); // false\n$num-\u003eisEven(); // true\n$num-\u003eisOdd(); // false\n$num-\u003eabs(); // 10.00\n$num-\u003enegate(); // -10.00\n$num-\u003emin(5); // 5.00\n$num-\u003emax(15); // 15.00\n$num-\u003eclamp(5, 15); // 10.00\n```\n\n## If methods\n\nEach operation has an `if` method, which returns the result of the operation, if the condition is true.\n\n```php\n$num = fnum(10, 2);\n\n$num-\u003eaddIf(2, false); // 10.00\n$num-\u003esubIf(2, false); // 10.00\n$num-\u003emulIf(2, false); // 10.00\n$num-\u003edivIf(2, false); // 10.00\n$num-\u003emodIf(3, false); // 10.00\n$num-\u003epowIf(2, false); // 10.00\n$num-\u003esqrtIf(false); // 10.00\n```\n\n# Testing\n\n```bash\n./vendor/bin/pest\n```\n\n# License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fillegalstudio%2Ffluent-bcmath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fillegalstudio%2Ffluent-bcmath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fillegalstudio%2Ffluent-bcmath/lists"}