dynoser/pricefinder
Composer 安装命令:
composer require dynoser/pricefinder
包简介
Searches a string for values similar to price and returns an array of those
README 文档
README
Overview
PriceFinder is a PHP class designed to detect and analyze price information in text strings. It's especially useful for processing multi-currency data, with support for a wide range of global currencies and cryptocurrencies.
Features
- Currency Support: The class can recognize and work with a diverse set of currencies, including major ones like USD, EUR, and GBP, along with popular cryptocurrencies like Bitcoin (BTC), Ethereum (ETH), and Dogecoin (DOGE).
- Flexible Text Analysis: It can find prices within text strings, even when they're presented in various formats or surrounded by different types of text.
- Customizable Prefixes and Suffixes: Users can define their own prefixes and suffixes for price detection, in addition to the default ones provided.
- Multi-Language Support: The class recognizes price prefixes in multiple languages, enhancing its usability in international contexts.
How It Works
- Initialization: The constructor initializes currency codes and symbols, along with default and customizable prefixes and suffixes for price detection.
- Price Detection: The
findPricesmethod scans a given text string for price-related patterns, including currency symbols and numeric values. - Currency Recognition: It determines the currency by analyzing the prefixes, suffixes, and actual symbols used in the text.
- Result Compilation: The method returns an array of detected prices with detailed information like the full matched string, the numeric value, and the identified currency.
Usage Example
$priceFinder = new dynoser\textworks\PriceFinder(); $pricesArr = $priceFinder->findPrices("The price is $100 or €85.33, or 8,000 рублей"); print_r($pricesArr); // This will return an array with details of the detected prices in USD and EUR: Array ( [0] => Array ( [full_match] => $100 or [digits] => 100 [currency] => USD [match_position] => 13 ) [1] => Array ( [full_match] => €85.33 [digits] => 85.33 [currency] => EUR [match_position] => 21 ) [2] => Array ( [full_match] => 8,000 рублей [digits] => 8000 [currency] => RUB [match_position] => 33 ) )
Customization
- Adding Custom Prefixes/Suffixes: Users can add their own prefixes or suffixes by passing them as arrays to the constructor or using
setPrefixesandsetSuffixesmethods. - Support for Additional Currencies: The class can be extended to support more currencies by updating the
$currenciesArrarray.
Limitations
- Language Dependency: While the class supports multiple languages, it may require customization for optimal performance in specific linguistic contexts.
- Complex Formats: Extremely complex or unconventional price formats might not be detected accurately.
Conclusion
The PriceFinder class is a versatile tool for detecting and analyzing prices in text, supporting a wide range of currencies and languages. It is highly customizable, making it suitable for various applications where price data extraction from text is required.
dynoser/pricefinder 适用场景与选型建议
dynoser/pricefinder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 12 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「price」 「parsing」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dynoser/pricefinder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dynoser/pricefinder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dynoser/pricefinder 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Implementation of the Omnibus Directive for Sylius application.
A port of the PEAR Net_HL7 library to PHP5.3+
An MT940 bank statement parser for PHP
Html5 stream tokenizer/reader (not using libxml)
Rudl UDP cluster logging library (PSR4 compliant)
Scrapping TOP10 Yandex Market Reviews
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2023-12-04