{"id":19352037,"url":"https://github.com/mockingmagician/moneysaurus","last_synced_at":"2025-04-23T07:31:13.061Z","repository":{"id":57018730,"uuid":"191253183","full_name":"MockingMagician/moneysaurus","owner":"MockingMagician","description":"Money change library. A Solution for change-making problem.","archived":false,"fork":false,"pushed_at":"2019-07-21T17:44:49.000Z","size":122,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-02T09:51:15.343Z","etag":null,"topics":["change","change-making","money","problem","problem-solving"],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/MockingMagician.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-10T22:16:24.000Z","updated_at":"2020-10-15T20:36:05.000Z","dependencies_parsed_at":"2022-08-22T20:20:18.516Z","dependency_job_id":null,"html_url":"https://github.com/MockingMagician/moneysaurus","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MockingMagician%2Fmoneysaurus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MockingMagician%2Fmoneysaurus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MockingMagician%2Fmoneysaurus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MockingMagician%2Fmoneysaurus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MockingMagician","download_url":"https://codeload.github.com/MockingMagician/moneysaurus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250391153,"owners_count":21422849,"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":["change","change-making","money","problem","problem-solving"],"created_at":"2024-11-10T04:37:57.104Z","updated_at":"2025-04-23T07:31:11.307Z","avatar_url":"https://github.com/MockingMagician.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://circleci.com/gh/MockingMagician/moneysaurus/tree/master.svg?style=shield)](https://circleci.com/api/v1.1/project/github/MockingMagician/moneysaurus/latest/artifacts)\n[![Latest Stable Version](https://poser.pugx.org/mocking-magician/moneysaurus/v/stable)](https://packagist.org/packages/mocking-magician/moneysaurus)\n[![Total Downloads](https://poser.pugx.org/mocking-magician/moneysaurus/downloads)](https://packagist.org/packages/mocking-magician/moneysaurus)\n[![License](https://poser.pugx.org/mocking-magician/moneysaurus/license)](https://packagist.org/packages/mocking-magician/moneysaurus)\n[![composer.lock](https://poser.pugx.org/mocking-magician/moneysaurus/composerlock)](https://packagist.org/packages/mocking-magician/moneysaurus)\n[![coverage](https://img.shields.io/endpoint.svg?url=https://raw.githubusercontent.com/MockingMagician/moneysaurus/master/.metadata/coverage.json)](https://packagist.org/packages/mocking-magician/moneysaurus)\n[![phpcs](https://img.shields.io/endpoint.svg?url=https://raw.githubusercontent.com/MockingMagician/moneysaurus/master/.metadata/php_cs_fixer.json)](https://packagist.org/packages/mocking-magician/moneysaurus)\n[![phpstan](https://img.shields.io/endpoint.svg?url=https://raw.githubusercontent.com/MockingMagician/moneysaurus/master/.metadata/phpstan.json)](https://packagist.org/packages/mocking-magician/moneysaurus)\n\n# Description\n\nMoneysaurus is a PHP library for the change-making problem.\n\nThe change-making problem addresses the question of finding the minimum number of coins (of certain denominations) that add up to a given amount of money.\n\nThis library works for every currency. Just start by defining a system. A system is a collection of coin and/or bank note values that can be used for change.\n\n# Install\n\nSimply run \n````bash\ncomposer require mocking-magician/moneysaurus\n````\n\n# Examples\n\nYou can just start by creating a system\n\n````PHP\n\u003c?\n\nuse MockingMagician\\Moneysaurus\\System;\nuse MockingMagician\\Moneysaurus\\QuantifiedSystem;\nuse MockingMagician\\Moneysaurus\\Algorithms\\GreedyAlgorithm;\n\n// There, you can see an example with the Euro currency system \n$euroSystem = new System(...[\n    0.01, \n    0.02, \n    0.05, \n    0.10, \n    0.20, \n    0.50, \n    1.0,  \n    2.0,  \n    5.0,  \n    10.0, \n    20.0, \n    50.0, \n    100.0,\n    200.0,\n    500.0,\n]);\n\n// Then initialize a quantified system.\n// A quantified system, is a system with a defined quantity of each coin/bank note available.\n\n$quantifiedSystem = new QuantifiedSystem($euroSystem);\n// By default, each value has been initialized with an zero amount quantity value.\n// So after you can set the available quantity for each coin/bank note\n$quantifiedSystem-\u003esetQuantity(0.01,  50);\n$quantifiedSystem-\u003esetQuantity(0.02,  50);\n$quantifiedSystem-\u003esetQuantity(0.05,  50);\n$quantifiedSystem-\u003esetQuantity(0.10,  50);\n$quantifiedSystem-\u003esetQuantity(0.20,  50);\n$quantifiedSystem-\u003esetQuantity(0.50,  50);\n$quantifiedSystem-\u003esetQuantity(1.0,   50);\n$quantifiedSystem-\u003esetQuantity(2.0,   50);\n$quantifiedSystem-\u003esetQuantity(5.0,   50);\n$quantifiedSystem-\u003esetQuantity(10.0,  50);\n$quantifiedSystem-\u003esetQuantity(20.0,  50);\n$quantifiedSystem-\u003esetQuantity(50.0,  50);\n$quantifiedSystem-\u003esetQuantity(100.0, 50);\n$quantifiedSystem-\u003esetQuantity(200.0, 50);\n$quantifiedSystem-\u003esetQuantity(500.0, 50);\n\n$resolver = new GreedyAlgorithm($quantifiedSystem);\n$change = $resolver-\u003echange(11.21);\n\n````\n\nAn other solution consist to initialize an empty quantified system, and then add system values with their available quantities.\n\n````PHP\n\u003c?\n\nuse MockingMagician\\Moneysaurus\\QuantifiedSystem;\nuse MockingMagician\\Moneysaurus\\Algorithms\\GreedyAlgorithm;\n\n$quantifiedSystem = new QuantifiedSystem();\n$quantifiedSystem-\u003eaddValue(0.01,  50);\n$quantifiedSystem-\u003eaddValue(0.02,  50);\n$quantifiedSystem-\u003eaddValue(0.05,  50);\n$quantifiedSystem-\u003eaddValue(0.10,  50);\n$quantifiedSystem-\u003eaddValue(0.20,  50);\n$quantifiedSystem-\u003eaddValue(0.50,  50);\n$quantifiedSystem-\u003eaddValue(1.0,   50);\n$quantifiedSystem-\u003eaddValue(2.0,   50);\n$quantifiedSystem-\u003eaddValue(5.0,   50);\n$quantifiedSystem-\u003eaddValue(10.0,  50);\n$quantifiedSystem-\u003eaddValue(20.0,  50);\n$quantifiedSystem-\u003eaddValue(50.0,  50);\n$quantifiedSystem-\u003eaddValue(100.0, 50);\n$quantifiedSystem-\u003eaddValue(200.0, 50);\n$quantifiedSystem-\u003eaddValue(500.0, 50);\n\n$resolver = new GreedyAlgorithm($quantifiedSystem);\n$change = $resolver-\u003echange(11.21);\n\n````\n\n# What's next ?\n\n- [ ] Adding one global resolver object who can have multiple resolver algorithms.\n- [ ] Creating an interface for system object recorder.\n- [ ] Adding a deduce method into quantified system.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmockingmagician%2Fmoneysaurus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmockingmagician%2Fmoneysaurus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmockingmagician%2Fmoneysaurus/lists"}