vistag / price-parser
Parse string and return separated price and currency
v1.0.2
2018-05-01 09:33 UTC
Requires
- php: ^5.4 || ^7.0
Requires (Dev)
- jakub-onderka/php-parallel-lint: ^0.9.0
- phpunit/phpunit: ^4.7|^5.0
This package is not auto-updated.
Last update: 2026-03-01 13:26:16 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