ShopCurrency::Nice PHP Méthode

Nice() public méthode

public Nice ( )
    public function Nice()
    {
        $symbol = $this->config()->currency_symbol;
        $val = number_format(abs($this->value), 2, self::config()->decimal_delimiter, self::config()->thousand_delimiter);
        if ($this->config()->append_symbol) {
            $val = $val . ' ' . $symbol;
        } else {
            $val = $symbol . $val;
        }
        if ($this->value < 0) {
            return sprintf(self::config()->negative_value_format, $val);
        }
        return $val;
    }

Usage Example

 public function testField()
 {
     ShopCurrency::config()->currency_symbol = "X";
     ShopCurrency::config()->decimal_delimiter = "|";
     ShopCurrency::config()->thousand_delimiter = "-";
     ShopCurrency::config()->negative_value_format = "- %s";
     $field = new ShopCurrency("Price");
     $field->setValue(-12345.56);
     $this->assertEquals("- X12-345|56", $field->Nice());
 }