{"id":21467441,"url":"https://github.com/elusivecodes/fyreformatter","last_synced_at":"2025-07-15T05:31:35.374Z","repository":{"id":62551013,"uuid":"505047321","full_name":"elusivecodes/FyreFormatter","owner":"elusivecodes","description":"FyreFormatter is a free, open-source formatting library for PHP.","archived":false,"fork":false,"pushed_at":"2024-08-18T05:32:57.000Z","size":68,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-18T06:52:45.140Z","etag":null,"topics":["formater","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/elusivecodes.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}},"created_at":"2022-06-19T08:01:33.000Z","updated_at":"2024-08-18T05:32:49.000Z","dependencies_parsed_at":"2024-06-29T07:42:12.605Z","dependency_job_id":"670c8b40-c5e1-4200-a38d-0ca8e8f4d1d1","html_url":"https://github.com/elusivecodes/FyreFormatter","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreFormatter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreFormatter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreFormatter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreFormatter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elusivecodes","download_url":"https://codeload.github.com/elusivecodes/FyreFormatter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226017540,"owners_count":17560536,"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":["formater","php"],"created_at":"2024-11-23T08:18:07.706Z","updated_at":"2024-11-23T08:18:08.416Z","avatar_url":"https://github.com/elusivecodes.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FyreFormatter\r\n\r\n**FyreFormatter** is a free, open-source formatting library for *PHP*.\r\n\r\n\r\n## Table Of Contents\r\n- [Installation](#installation)\r\n- [Basic Usage](#basic-usage)\r\n- [Methods](#methods)\r\n\r\n\r\n\r\n## Installation\r\n\r\n**Using Composer**\r\n\r\n```\r\ncomposer require fyre/formatter\r\n```\r\n\r\nIn PHP:\r\n\r\n```php\r\nuse Fyre\\Utility\\Formatter;\r\n```\r\n\r\n\r\n## Basic Usage\r\n\r\n- `$typeParser` is a [*TypeParser*](https://github.com/elusivecodes/FyreTypeParser).\r\n- `$config` is a [*Config*](https://github.com/elusivecodes/FyreConfig).\r\n\r\n```php\r\n$formatter = new Formatter($typeParser, $config);\r\n```\r\n\r\nDefault configuration options will be resolved from the \"*App*\" key in the [*Config*](https://github.com/elusivecodes/FyreConfig).\r\n\r\n- `$options` is an array containing configuration options.\r\n    - `defaultLocale` is a string representing the default locale, and will default to the system default.\r\n    - `defaultTimeZone` is a string representing the default time zone, and will default to the system default.\r\n    - `defaultCurrency` is a string representing the default currency, and will default to \"*USD*\".\r\n\r\n```php\r\n$container-\u003euse(Config::class)-\u003eset('App', $options);\r\n```\r\n\r\n**Autoloading**\r\n\r\nIt is recommended to bind the *Formatter* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.\r\n\r\n```php\r\n$container-\u003esingleton(Formatter::class);\r\n```\r\n\r\nAny dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n\r\n```php\r\n$formatter = $container-\u003euse(Formatter::class);\r\n```\r\n\r\n\r\n## Methods\r\n\r\n**Currency**\r\n\r\nFormat a value as a currency string.\r\n\r\n- `$value` is a string or number representing the value to format.\r\n- `$options` is an array containing formatting options.\r\n    - `$locale` is a string representing the locale, and will default to the *Formatter* default locale.\r\n    - `$currency` is a string representing the currency, and will default to the *Formatter* default currency.\r\n\r\n```php\r\n$currency = $formatter-\u003ecurrency($value, $options);\r\n```\r\n\r\n**Date**\r\n\r\nFormat a [*DateTime*](https://github.com/elusivecodes/FyreDateTime) as a date string.\r\n\r\n- `$value` is a [*DateTime*](https://github.com/elusivecodes/FyreDateTime).\r\n- `$options` is an array containing formatting options.\r\n    - `$locale` is a string representing the locale, and will default to the *Formatter* default locale.\r\n    - `$timeZone` is a string representing the time zone, and will default to the *Formatter* default time zone.\r\n    - `$format` is a string representing the format, and will default to the [*TypeParser*](https://github.com/elusivecodes/FyreTypeParser) default date user format.\r\n\r\n```php\r\n$date = $formatter-\u003edate($value, $options);\r\n```\r\n\r\n**Date/Time**\r\n\r\nFormat a [*DateTime*](https://github.com/elusivecodes/FyreDateTime) as a date/time string.\r\n\r\n- `$value` is a [*DateTime*](https://github.com/elusivecodes/FyreDateTime).\r\n- `$options` is an array containing formatting options.\r\n    - `$locale` is a string representing the locale, and will default to the *Formatter* default locale.\r\n    - `$timeZone` is a string representing the time zone, and will default to the *Formatter* default time zone.\r\n    - `$format` is a string representing the format, and will default to the [*TypeParser*](https://github.com/elusivecodes/FyreTypeParser) default datetime user format.\r\n\r\n```php\r\n$datetime = $formatter-\u003edatetime($value, $options);\r\n```\r\n\r\n**Get Default Currency**\r\n\r\nGet the default currency.\r\n\r\n```php\r\n$defaultCurrency = $formatter-\u003egetDefaultCurrency();\r\n```\r\n\r\n**Get Default Locale**\r\n\r\nGet the default locale.\r\n\r\n```php\r\n$defaultLocale = $formatter-\u003egetDefaultLocale();\r\n```\r\n\r\n**Get Default Time Zone**\r\n\r\nGet the default time zone.\r\n\r\n```php\r\n$defaultTimeZone = $formatter-\u003egetDefaultTimeZone();\r\n```\r\n\r\n**Number**\r\n\r\nFormat a value as a number string.\r\n\r\n- `$value` is a string or number representing the value to format.\r\n- `$options` is an array containing formatting options.\r\n    - `$locale` is a string representing the locale, and will default to the *Formatter* default locale.\r\n\r\n```php\r\n$number = $formatter-\u003enumber($value, $options);\r\n```\r\n\r\n**Percent**\r\n\r\nFormat a value as a percent string.\r\n\r\n- `$value` is a string or number representing the value to format.\r\n- `$options` is an array containing formatting options.\r\n    - `$locale` is a string representing the locale, and will default to the *Formatter* default locale.\r\n\r\n```php\r\n$percent = $formatter-\u003epercent($value, $options);\r\n```\r\n\r\n**Set Default Currency**\r\n\r\nSet the default currency.\r\n\r\n- `$currency` is a string representing the currency code.\r\n\r\n```php\r\n$formatter-\u003esetDefaultCurrency($currency);\r\n```\r\n\r\n**Set Default Locale**\r\n\r\nSet the default locale.\r\n\r\n- `$locale` is a string representing the locale.\r\n\r\n```php\r\n$formatter-\u003esetDefaultLocale($locale);\r\n```\r\n\r\n**Set Default Time Zone**\r\n\r\nSet the default time zone.\r\n\r\n- `$timeZone` is a string representing the time zone.\r\n\r\n```php\r\n$formatter-\u003esetDefaultTimeZone($timeZone);\r\n```\r\n\r\n**Time**\r\n\r\nFormat a [*DateTime*](https://github.com/elusivecodes/FyreDateTime) as a time string.\r\n\r\n- `$value` is a [*DateTime*](https://github.com/elusivecodes/FyreDateTime).\r\n- `$options` is an array containing formatting options.\r\n    - `$locale` is a string representing the locale, and will default to the *Formatter* default locale.\r\n    - `$timeZone` is a string representing the time zone, and will default to the *Formatter* default time zone.\r\n    - `$format` is a string representing the format, and will default to the [*TypeParser*](https://github.com/elusivecodes/FyreTypeParser) default time user format.\r\n\r\n```php\r\n$time = $formatter-\u003etime($value, $options);\r\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyreformatter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felusivecodes%2Ffyreformatter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyreformatter/lists"}