vistag/price-parser

解析字符串并返回分离的价格和货币

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

This package is not auto-updated.

Last update: 2024-09-15 04:42:12 UTC


README

从给定字符串中提取价格和货币

安装

您可以通过composer使用以下命令安装此包

 composer require vistag/price-parser

用法

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

支持

如果您认为您发现了一个问题,请使用 GitHub问题跟踪器 报告问题,或者更好的方法是,分支存储库并提交一个拉取请求。

如果您正在使用此包,我很乐意听听您的想法。谢谢!

许可

MIT许可(MIT)。 Vistag.com