Overview

Packages

  • blesta
    • app
      • controllers
      • models
    • components
      • auth
        • ldap
        • motp
        • oath
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • events
      • exchange
        • rates
          • currency
            • layer
          • fixer
          • open
            • exchange
              • rates
          • x
            • rates
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
          • perforated
            • invoice
          • quickbooks
            • invoice
          • templates
            • default
      • modules
      • net
        • amazon
          • s3
        • http
        • net
          • geo
            • ip
      • plugins
      • reports
        • aging
          • invoices
        • client
          • data
            • portability
        • custom
          • report
        • invoice
          • creation
        • package
          • revenue
        • tax
          • liability
        • transactions
          • applied
          • received
      • security
      • session
        • cart
      • settingscollection
      • upgrades
        • tasks
      • upload
      • vcard
    • core
      • Automation
        • Tasks
          • Common
          • Task
        • Type
          • Common
          • Cron
      • Pricing
        • ItemComparator
        • MetaItem
        • Modifier
          • Type
            • Description
              • Type
                • Discount
                • Option
                • Service
                • Tax
            • Discount
            • Price
            • Proration
        • Presenter
          • Build
            • Invoice
            • InvoiceData
            • Options
            • Service
            • ServiceChange
            • ServiceData
          • Collection
          • Format
            • Fields
            • Type
              • Discount
              • Item
              • Option
              • Options
              • Package
              • Pricing
              • Service
              • Tax
          • Items
            • Invoice
            • Service
          • Type
      • ServiceProviders
      • Util
        • Captcha
          • Captchas
          • Common
        • Common
          • Traits
        • Events
          • Common
          • Handlers
          • Observers
        • Filters
          • Common
        • GeoIp
        • Input
          • Fields
            • Common
        • Tax
        • Widgets
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
      • widget
        • client
  • minPHP
    • helpers
      • color
      • data
        • structure
  • None
  • PHP

Classes

  • CurrencyFormat
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated

Class CurrencyFormat

Currency Format Helper

Provides conversion routines to and from currency strings and float values. Uses Blesta's Currencies model which provides automatic caching for increased performance.

Package: blesta\helpers\currency\format
Copyright: Copyright (c) 2010, Phillips Data, Inc.
License: The Blesta License Agreement
Link: Blesta
Located at helpers/currency_format/currency_format.php
Methods summary
public
# __construct( integer $company_id = null )

Construct a new CurrencyFormat object

Construct a new CurrencyFormat object

Parameters

$company_id
The ID of the company to work off of

See

CurrencyFormat::setCompany()
public integer
# setCompany( integer $company_id )

Set the company ID to work off of

Set the company ID to work off of

Parameters

$company_id
The ID of the company to work off of

Returns

integer
Returns the ID of the previously set company ID (null of none set)
public string
# format( float $value, string $currency, array $options = null )

Formats the float value into a currency string. Conversions are cached to provide increased performance. To clear cache see CurrencyFormat::clear()

Formats the float value into a currency string. Conversions are cached to provide increased performance. To clear cache see CurrencyFormat::clear()

Parameters

$value
The decimal value to convert
$currency
The ISO 4217 currency code format to apply to $value
$options

An array of options to control the format (optional), if not set the options are pulled from the company settings. Options include:

  • prefix Whether or not to include the prefix symbol (if one exists) true/false default true
  • suffix Whether or not to include the suffix symbold (if one exists) true/false default true
  • code Whether or not to include the currency code in the result (if one exists) true/false default company setting
  • with_separator Whether or not to include the separator (, or sometimes . or space) in the result true/false default true
  • html_code Whether or not to wrap the currency code with HTML true/false (default false). If true, will produce currency code like USD
  • decimals The number of decimal places (precision) (optional, default null to use the currency's defined precision)

Returns

string
The formatted value

See

CurrencyFormat::cast()
CurrencyFormat::clear()
public string
# cast( string $value, string $currency, integer $decimals = null )

Casts the currency string into a float value. Conversions are cached to provide increased performance. To clear cache see CurrencyFormat::clear()

Casts the currency string into a float value. Conversions are cached to provide increased performance. To clear cache see CurrencyFormat::clear()

Parameters

$value
A currency value
$currency
The ISO 4217 currency code format representing $value
$decimals

The number of decimal places (precision) (optional, default null to use the currency's defined precision)

Returns

string
The value in decimal format based on ISO 31-0

See

CurrencyFormat::format()
CurrencyFormat::clear()
public
# truncateDecimal( string $value, integer $min, char $decimal_char = '.' )

Removes trailing zeros from a string preserving $min decimal places

Removes trailing zeros from a string preserving $min decimal places

Parameters

$value
The decimal value in string format
$min
The minimum number of decimal places
$decimal_char
The character used in $value for decimal representation

Retrun

string The format decimal value with trailing zeros removed up to the $min value
public
# clear( )

Clears the currency format cache. Useful if you made modifications to the currency settings and need to continue conversion using those new settings.

Clears the currency format cache. Useful if you made modifications to the currency settings and need to continue conversion using those new settings.

Blesta API documentation generated by ApiGen