formatToNumber() public static method

Defaults to 2 decimal places
public static formatToNumber ( $value, integer $decimals = 2 ) : null | string
$value
$decimals integer
return null | string
Beispiel #1
0
 /**
  * Cost in percent. Range of 0 to 100.
  *
  * @param string $percent
  * 
  * @return $this
  */
 public function setPercent($percent)
 {
     NumericValidator::validate($percent, "Percent");
     $percent = FormatConverter::formatToNumber($percent);
     $this->percent = $percent;
     return $this;
 }
 public function testFormatToNumberDecimals()
 {
     $result = FormatConverter::formatToNumber("0.0", 4);
     $this->assertEquals("0.0000", $result);
 }