Skip to content

FyreFormatter is a free, open-source formatting library for PHP.

License

Notifications You must be signed in to change notification settings

elusivecodes/FyreFormatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FyreFormatter

FyreFormatter is a free, open-source formatting library for PHP.

Table Of Contents

Installation

Using Composer

composer require fyre/formatter

In PHP:

use Fyre\Utility\Formatter;

Methods

Currency

Format a value as a currency string.

  • $value is a string or number representing the value to format.
  • $options is an array containing formatting options.
    • $locale is a string representing the locale, and will default to the Formatter default locale.
    • $currency is a string representing the currency, and will default to the Formatter default currency.
$currency = Formatter::currency($value, $options);

Date

Format a DateTime as a date string.

  • $value is a DateTime.
  • $options is an array containing formatting options.
    • $locale is a string representing the locale, and will default to the Formatter default locale.
    • $timeZone is a string representing the time zone, and will default to the Formatter default time zone.
    • $format is a string representing the format, and will default to the TypeParser default date user format.
$date = Formatter::date($value, $options);

Date/Time

Format a DateTime as a date/time string.

  • $value is a DateTime.
  • $options is an array containing formatting options.
    • $locale is a string representing the locale, and will default to the Formatter default locale.
    • $timeZone is a string representing the time zone, and will default to the Formatter default time zone.
    • $format is a string representing the format, and will default to the TypeParser default datetime user format.
$datetime = Formatter::datetime($value, $options);

Get Default Currency

Get the default currency.

$defaultCurrency = Formatter::getDefaultCurrency();

Get Default Locale

Get the default locale.

$defaultLocale = Formatter::getDefaultLocale();

Get Default Time Zone

Get the default time zone.

$defaultTimeZone = Formatter::getDefaultTimeZone();

Number

Format a value as a number string.

  • $value is a string or number representing the value to format.
  • $options is an array containing formatting options.
    • $locale is a string representing the locale, and will default to the Formatter default locale.
$number = Formatter::number($value, $options);

Percent

Format a value as a percent string.

  • $value is a string or number representing the value to format.
  • $options is an array containing formatting options.
    • $locale is a string representing the locale, and will default to the Formatter default locale.
$percent = Formatter::percent($value, $options);

Set Default Currency

Set the default currency.

  • $currency is a string representing the currency code.
Formatter::setDefaultCurrency($currency);

Set Default Locale

Set the default locale.

  • $locale is a string representing the locale.
Formatter::setDefaultLocale($locale);

Set Default Time Zone

Set the default time zone.

  • $timeZone is a string representing the time zone.
Formatter::setDefaultTimeZone($timeZone);

Time

Format a DateTime as a time string.

  • $value is a DateTime.
  • $options is an array containing formatting options.
    • $locale is a string representing the locale, and will default to the Formatter default locale.
    • $timeZone is a string representing the time zone, and will default to the Formatter default time zone.
    • $format is a string representing the format, and will default to the TypeParser default time user format.
$time = Formatter::time($value, $options);

About

FyreFormatter is a free, open-source formatting library for PHP.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages