You are here

public static function Input::parseAmountNegativeFormat in Currency 7.2

Parses a negative amount.

Parameters

string $amount:

Return value

string The amount with negative formatting replaced by a minus sign prefix.

1 call to Input::parseAmountNegativeFormat()
Input::parseAmount in currency/vendor/bartfeenstra/currency/src/BartFeenstra/Currency/Input.php
Parses an amount.

File

currency/vendor/bartfeenstra/currency/src/BartFeenstra/Currency/Input.php, line 83
Contains class \BartFeenstra\Currency\Input.

Class

Input
Helpers for parsing user input.

Namespace

BartFeenstra\Currency

Code

public static function parseAmountNegativeFormat($amount) {

  // An amount wrapped in parentheses.
  $amount = preg_replace('/^\\((.*?)\\)$/', '-\\1', $amount);

  // An amount suffixed by a minus sign.
  $amount = preg_replace('/^(.*?)-$/', '-\\1', $amount);

  // Double minus signs.
  $amount = preg_replace('/--/', '', $amount);
  return $amount;
}