{"id":13601120,"url":"https://github.com/php-collective/decimal-object","last_synced_at":"2026-01-31T23:48:30.062Z","repository":{"id":198585188,"uuid":"701102926","full_name":"php-collective/decimal-object","owner":"php-collective","description":"Decimal handling as value object instead of plain strings or floats.","archived":false,"fork":false,"pushed_at":"2025-04-03T22:30:19.000Z","size":108,"stargazers_count":23,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-25T22:52:29.338Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/php-collective.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,"zenodo":null}},"created_at":"2023-10-05T23:30:37.000Z","updated_at":"2025-04-03T22:28:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"e74994be-ffb8-4bfc-b4e8-f1229d1f8abe","html_url":"https://github.com/php-collective/decimal-object","commit_stats":null,"previous_names":["php-collective/decimal-object"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/php-collective/decimal-object","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-collective%2Fdecimal-object","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-collective%2Fdecimal-object/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-collective%2Fdecimal-object/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-collective%2Fdecimal-object/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-collective","download_url":"https://codeload.github.com/php-collective/decimal-object/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-collective%2Fdecimal-object/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28961124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T23:03:11.038Z","status":"ssl_error","status_checked_at":"2026-01-31T22:56:44.691Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-08-01T18:00:56.027Z","updated_at":"2026-01-31T23:48:30.033Z","avatar_url":"https://github.com/php-collective.png","language":"PHP","readme":"#  Decimal Object\n\n[![CI](https://github.com/php-collective/decimal-object/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/php-collective/decimal-object/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/php-collective/decimal-object/branch/master/graph/badge.svg?token=L1thFB9nOG)](https://codecov.io/gh/php-collective/decimal-object)\n[![Latest Stable Version](https://poser.pugx.org/php-collective/decimal-object/v/stable.svg)](https://packagist.org/packages/php-collective/decimal-object)\n[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.1-8892BF.svg)](https://php.net/)\n[![PHPStan](https://img.shields.io/badge/PHPStan-level%208-brightgreen.svg?style=flat)](https://phpstan.org/)\n[![License](https://poser.pugx.org/php-collective/decimal-object/license)](https://packagist.org/packages/php-collective/decimal-object)\n\nDecimal value object for PHP.\n\n## Background\nWhen working with decimal (e.g. monetary) values, normal data types like int or float are not suitable for exact arithmetic.\nTry out the following in PHP:\n```php\nvar_dump(0.1 + 0.2);        // float(0.3)\nvar_dump(0.1 + 0.2 - 0.3);  // float(5.5511151231258E-17)\n```\n\nHandling them as strings is a workaround, but as value object you can more easily encapsulate some of the logic.\n\n### Alternatives\nSolutions like [php-decimal](https://php-decimal.github.io/#introduction) require a custom PHP extension (would make it faster, but also more difficult for some\nservers to be available). \nMonetary values themselves could be handled also with [brick/money](https://github.com/brick/money) or [moneyphp/money](https://github.com/moneyphp/money).\n\nFor details see the [wiki](https://github.com/php-collective/decimal-object/wiki).\n\nNote: If you are looking for pre PHP 8.1 versions, check out the [legacy library](https://github.com/spryker/decimal-object).\n\n## Features\n\n- Super strict on precision/scale. Does not lose significant digits on its own. You need to `trim()` for this manually.\n- Speaking API (no le, gt methods).\n- Basic math operations and checks supported.\n- Immutability.\n- Handle very large and very small numbers.\n\n## Installation\n\n### Requirements\n\n- `bcmath` PHP extension enabled\n\n### Composer (preferred)\n```\ncomposer require php-collective/decimal-object\n```\n\n## Usage\n\nSee [Documentation](/docs) for more details.\n\n## Implementations\nThe following libraries are using the `Decimal` value object:\n\n- [dereuromark/cakephp-decimal](https://github.com/dereuromark/cakephp-decimal) as decimal type replacement for CakePHP ORM.\n\nThe original library here was written 2019 for [Spryker](https://spryker.com/) ecommerce framework\nand since then battle-tested through millions of customers and orders as well as other complex calculations under the hood.\nThis here is the freshly upgraded and independently maintained version for the PHP ecosystem as a whole.\n\nEnjoy!\n","funding_links":[],"categories":["Repositories","Table of Contents"],"sub_categories":["Numbers"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-collective%2Fdecimal-object","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-collective%2Fdecimal-object","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-collective%2Fdecimal-object/lists"}