vistag / price-parser
Parse string and return separated price and currency
Installs: 2 808
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 1
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: 2024-10-27 05:25:39 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