{"id":17134357,"url":"https://github.com/brianium/nomnom","last_synced_at":"2025-04-13T08:55:19.139Z","repository":{"id":10154627,"uuid":"12233761","full_name":"brianium/nomnom","owner":"brianium","description":"A simple library for converting byte sizes with PHP 5.3+","archived":false,"fork":false,"pushed_at":"2014-10-28T14:46:41.000Z","size":364,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T22:46:53.976Z","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":"51Degrees/Device-Detection","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brianium.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}},"created_at":"2013-08-20T03:31:50.000Z","updated_at":"2023-10-10T12:48:45.000Z","dependencies_parsed_at":"2022-09-13T13:51:03.661Z","dependency_job_id":null,"html_url":"https://github.com/brianium/nomnom","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brianium%2Fnomnom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brianium%2Fnomnom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brianium%2Fnomnom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brianium%2Fnomnom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brianium","download_url":"https://codeload.github.com/brianium/nomnom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248554052,"owners_count":21123576,"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":[],"created_at":"2024-10-14T19:44:42.096Z","updated_at":"2025-04-13T08:55:19.121Z","avatar_url":"https://github.com/brianium.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"#Nomnom [![Build Status](https://travis-ci.org/brianium/nomnom.png?branch=master)](https://travis-ci.org/brianium/nomnom)\n\u003e Get it? Bytes? Bites?\n\nNomnom handles file size conversion for PHP 5.3+. It handles both binary (base 2)\nand metric (base 10) conversions. It provides a simple interface for converting between\nsizes of any similar base!\n\nUsage\n-----\nA Nomnom object is constructed with a \"start\" value that will be converted.\nTwo methods are defined on this object: `from` and `to`. Each of these methods takes\na metric or binary unit to convert from/to.\n\nThe `to` method takes an optional `precision` value to specify how many significant\ndigits to keep in the result.\n\n```php\n$nomnom = new Nomnom(1440000);\n\n//metric conversion to 1.44\n$mb = $nomnom-\u003efrom('B')-\u003eto('MB', 2);\n\n$nomnom = new Nomnom(1024);\n\n//binary conversion to 1\n$kb = $nomnom-\u003efrom('KiB')-\u003eto('MiB');\n\n//convert a file size\n$filesize = new Filesize('/path/to/file.txt');\n$mb = $filesize-\u003eto('MB');\n```\n\nAs a convenience, Nomnom provides a factory method called `nom` and constants for the metric\nand binary units.\n\n```php\n//returns 1.44\nNomnom::nom(1440000)-\u003efrom(Nomnom::BYTES)-\u003eto(Nomnom::MB, 2);\n\n//factory for Filesize\nNomnom::file('/path/to/file.txt')-\u003eto(Nomnom::MB);\n```\n\nNotes\n-----\n'B' refers to bytes in either base 10 or base 2.\n\nNomnom will throw a `ConversionException` if the `from` and `to` methods contain units\nfor different bases, i.e no `$nomnom-\u003efrom('KiB')-\u003eto('MB');`\n\nNomnom requires the bcmath extension to handle greater precision.\n\nTests\n-----\nTo run the tests, make sure dependencies have been installed with `composer install --dev` and run:\n\n```bash\nvendor/bin/phpunit test/\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrianium%2Fnomnom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrianium%2Fnomnom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrianium%2Fnomnom/lists"}