Set price and return sanitized value at once.

@param mixed  $price
@param string $format [optional] the type of $price, default ConvertPrice::EURO.

@return float|int
@throws InvalidArgumentException
183499
public function sanitize($price, $format = self::EURO)
    {
        return $this->setPrice($price, $format)->getPrice($format);
    }
553652
public static function validateFormatType($formatType)
    {
        if (!in_array($formatType, [self::FORMAT_TYPE_DECIMAL, self::FORMAT_TYPE_PERCENT, self::FORMAT_TYPE_CURRENCY])) {
            throw new Exception\InvalidFormatTypeException('Provided formatType, "' . $formatType . '", is not one of allowed values.', 1281439179);
        }
    }
1322307
public function setFormat($format)
    {
        if (!is_null($format)) {
            $this->format = $format;
            $this->useFormat(false);
        }

        return $this;
    }
917048
public function formatPrice(float $price, $baseCurrency = null, $targetCurrency = null, $locale = null, $quantity = 1) : string
    {
        return $this->helper->convertAndFormat($price, $baseCurrency, $targetCurrency, $quantity, $locale);
    }
47769
protected function dateFormatter($dateTime, $format)
    {
        if (is_numeric($dateTime)) {
            return gmdate($format, (int) $dateTime);
        }

        if (is_string($dateTime)) {
            $dateTime = new \DateTime($dateTime);
        }

        if ($dateTime instanceof \DateTimeInterface) {
            static $utc;
            if (!$utc) {
                $utc = new \DateTimeZone('UTC');
            }
            return $dateTime->setTimezone($utc)->format($format);
        }

        throw new \InvalidArgumentException('Date/Time values must be either '
            . 'be a string, integer, or DateTime object');
    }
380246
public function price($format = true, $taxedItemsOnly = true)
    {
        $price = $this->price;

        if (isset($this->items)) {
            foreach ($this->items as $item) {
                if ($taxedItemsOnly && !$item->taxable) {
                    continue;
                }
                $price += $item->price(false, $taxedItemsOnly);
            }
        }

        return LaraCart::formatMoney($price, $this->locale, $this->internationalFormat, $format);
    }
356630
public function format($format)
    {
        if(Format::exist($format))
            $this->format = Format::get($format);
        else
            Format::invalidType();

        return $this;
    }
966796
private function priceAdjuster($price) {
        // min,max, value
        $price_ranges = [
            [01, 29, 29],
            [30, 49, 49],
            [50, 79, 79],
            [80, 99, 99],
            [00, 00, 99],
        ];

        list($whole, $decimal) = explode('.', $price);

        foreach ($price_ranges as &$value) {
            if($decimal >= $value[0] && $decimal <= $value[1]) {
                $decimal = $value[2];
                break;
            }
        }

        $price = $whole.'.'.$decimal;

        return floatval($price);
    }
1115535
public function formatPrice($price)
    {
        $currencies = new ISOCurrencies();

        $numberFormatter = new \NumberFormatter($this->locale, \NumberFormatter::CURRENCY);
        $moneyFormatter = new IntlMoneyFormatter($numberFormatter, $currencies);

        return $moneyFormatter->format($price);
    }
80215
public static function fromString($date, $format = \DateTime::ATOM)
    {
        $dateTime = \DateTime::createFromFormat($format, $date);

        $err = \DateTime::getLastErrors();
        if ($err['error_count'] > 0) {
            throw new \InvalidArgumentException(sprintf('%s', implode(', ', $err['errors'])));
        }

        return self::fromDateTime($dateTime);
    }
317523
public function format(string $format)
    {
        if (! $this->validateManipulation($format, 'format')) {
            throw InvalidManipulation::invalidParameter(
                'format',
                $format,
                $this->getValidManipulationOptions('format')
            );
        }

        return $this->addManipulation('format', $format);
    }
1370889
public function formatPrice($price, $currency, $locale = null)
    {
        return $this->priceManager->getFormattedPrice($price, $currency, $locale);
    }
1064988
public static function setPrice($validator, $price, $currency, $type = null, $resolution = null)
    {
        self::$xml['price'] .= '<video:price';
        self::setPriceValue($validator, $price);
        self::setPriceCurrency($validator, $currency);
        self::setPriceType($validator, $type);
        self::setPriceResolution($validator, $resolution);
        self::$xml['price'] .= '>'.$price.'</video:price>';

        return self::$xml['price'];
    }
219566
public function getAmount($amount)
    {
        if (!is_float($amount) &&
            $this->getCurrencyDecimalPlaces() > 0 &&
            false === strpos((string) $amount, '.')) {
            throw new InvalidArgumentException(
                'Please specify amount as a string or float, '.
                'with decimal places (e.g. \'10.00\' to represent $10.00).'
            );
        }

        return $this->formatCurrency($amount);
    }
929128
public function dateFormat($date, $format = '%e %b %Y')
    {
        if ($date instanceof \DateTime) {
            $ts = $date->getTimestamp();
        } elseif (is_numeric($date)) {
            $ts = $date;
        } elseif (preg_match('/^[0-9]{4,4}-[0-9]{2,2}-[0-9]{2,2}T[0-9]{2,2}:[0-9]{2,2}.*/', $date)) {
            // timestamp format 2013-01-01T00:00:00
            $ts = new \DateTime($date);
            $ts = $ts->getTimestamp();
        } else {
            throw new \InvalidArgumentException(sprintf("Cannot format %s as a date", $date));
        }

        return strftime($format, $ts);
    }
236324
def format_price(self, price):
        
        # ensure we have a float
        price = api.to_float(price, default=0.0)
        dm = self.get_decimal_mark()
        cur = self.get_currency_symbol()
        price = "%s %.2f" % (cur, price)
        return price.replace(".", dm)
1335081
public function transform( $prices )
	{
		$html = '';
		$enc = $this->encoder();
		$format = $this->_getFormat();
		$iface = 'MShop_Price_Item_Interface';

		if( !is_array( $prices ) ) {
			$prices = array( $prices );
		}

		foreach( $prices as $priceItem )
		{
			if( !( $priceItem instanceof $iface ) ) {
				throw new MW_View_Exception( sprintf( 'Object doesn\'t implement "%1$s"', $iface ) );
			}

			$costs = $priceItem->getCosts();
			$rebate = $priceItem->getRebate();
			$currency = $this->translate( 'client/html/currency', $priceItem->getCurrencyId() );

			$html .= '
			<div class="price-item">
				<span class="quantity">' . $enc->html( sprintf( $format['quantity'], $priceItem->getQuantity() ), $enc::TRUST ) . '</span>
				<span class="value">' . $enc->html( sprintf( $format['value'], $this->number( $priceItem->getValue() ), $currency ), $enc::TRUST ) . '</span>' .
				( $rebate > 0  ? '
				<span class="rebate">' . $enc->html( sprintf( $format['rebate'], $this->number( $rebate ), $currency ), $enc::TRUST ) . '</span>
				<span class="rebatepercent">' . $enc->html( sprintf( $format['rebate%'], $this->number( round( $rebate * 100 / ( $priceItem->getValue() + $rebate ) ), 0 ) ), $enc::TRUST ) . '</span>'
				: '' ) .
				( $costs > 0 ? '
				<span class="costs">' . $enc->html( sprintf( $format['costs'], $this->number( $costs ), $currency ), $enc::TRUST ) . '</span>'
				: '' ) .
				'<span class="taxrate">' . $enc->html( sprintf( $format['taxrate'], $this->number( $priceItem->getTaxrate() ) ), $enc::TRUST ) . '</span>
			</div>';
		}

		return $html;
	}