vistag/price-parser

Parse string and return separated price and currency

v1.0.2 2018-05-01 09:33 UTC

This package is not auto-updated.

Last update: 2024-04-28 02:37:46 UTC


README

Extract price and currency from given string

Installation

You can install this package via composer using this command:

 composer require vistag/price-parser

Usage

use Vistag\PriceParser\PriceParser;


$priceParser = new PriceParser('120 Kč');

$priceParser->getPrice();
// 120
$priceParser->getCurrency();
// CZK


$priceParser = new PriceParser('$ 1,210,000.10');

$priceParser->getPrice();
// 1210000.1
$priceParser->getCurrency();
// USD


$priceParser = new PriceParser('foobar');

$priceParser->isValid();
// false


$priceParser = new PriceParser('12312');

$priceParser->isValid();
// true
$priceParser->getPrice();
// 12312
$priceParser->getCurrency();
// null

Support

If you believe you have found an issue, please report it using the GitHub issue tracker, or better yet, fork the repository and submit a pull request.

If you're using this package, I'd love to hear your thoughts. Thanks!

License

The MIT License (MIT). Vistag.com