Punic APIs
  • Namespace
  • Class
  • Tree
  • Todo

Namespaces

  • Punic
    • Exception

Classes

  • Calendar
  • Comparer
  • Currency
  • Data
  • Language
  • Misc
  • Number
  • Phone
  • Plural
  • Territory
  • Unit

Exceptions

  • Exception

Class Number

Numbers helpers.

Namespace: Punic
Located at Number.php

Methods summary

public static boolean
# isNumeric( string $value, string $locale = '' )

Check if a variable contains a valid number for the specified locale.

Check if a variable contains a valid number for the specified locale.

Parameters

$value
The string value to check
$locale
The locale to use. If empty we'll use the default locale set in \Punic\Data

Returns

boolean
public static boolean
# isInteger( string $value, string $locale = '' )

Check if a variable contains a valid integer number for the specified locale.

Check if a variable contains a valid integer number for the specified locale.

Parameters

$value
The string value to check
$locale
The locale to use. If empty we'll use the default locale set in \Punic\Data

Returns

boolean
public static string
# format( integer|float|string $value, integer|null $precision = null, string $locale = '' )

Localize a number representation (for instance, converts 1234.5 to '1,234.5' in case of English and to '1.234,5' in case of Italian).

Localize a number representation (for instance, converts 1234.5 to '1,234.5' in case of English and to '1.234,5' in case of Italian).

Parameters

$value
The string value to convert
$precision
The wanted precision (well use http://php.net/manual/function.round.php)
$locale
The locale to use. If empty we'll use the default locale set in \Punic\Data

Returns

string
Returns an empty string $value is not a number, otherwise returns the localized representation of the number
public static integer|float|null
# unformat( string $value, string $locale = '' )

Convert a localized representation of a number to a number (for instance, converts the string '1,234' to 1234 in case of English and to 1.234 in case of Italian).

Convert a localized representation of a number to a number (for instance, converts the string '1,234' to 1234 in case of English and to 1.234 in case of Italian).

Parameters

$value
The string value to convert
$locale
The locale to use. If empty we'll use the default locale set in \Punic\Data

Returns

integer|float|null
Returns null if $value is not valid, the numeric value otherwise
Punic APIs API documentation generated by ApiGen