germania-kg / prices
1.0.2
2022-03-30 10:10 UTC
Requires
- php: ^5.6|^7.0
- container-interop/container-interop: ^1.1
Requires (Dev)
- php-coveralls/php-coveralls: ^2.0
- phpunit/phpunit: ^5.7|^6.0|^7.0
This package is auto-updated.
Last update: 2024-08-29 04:47:04 UTC
README
此包是从旧代码中提炼出来的!
您最好不想在生产中使用这个包。
安装
$ composer require germania-kg/prices
MySQL: 此包需要一个名为 germania_prices 的MySQL表,您可以使用 sql/
目录中的 germania_prices.sql
文件进行安装。
使用方法
PdoPrices 是一个用于检索任何给定文章ID的价格的可调用函数。它实现了container-interop(即将推出的PSR 11标准)。
<?php use Germania\Prices\PdoPrices; $prices_factory = new PdoPrices( $pdo ); $prices_factory = new PdoPrices( $pdo, "my_custom_table" ); // Assume article has ID 42 $article = ... // ContainerInterface: $complete = $prices_factory->has( 42 ); // Getting may throw NoPriceFoundException // Interop\Container\Exception\NotFoundException) $prices = $prices_factory->get( 42 ); // Avoid Exception using __invoke: // Returns always array, may be empty: $prices = $prices_factory( 42 ); ?>
开发
$ git clone https://github.com/GermaniaKG/Prices.git
$ cd Prices
$ composer install
单元测试
可以将 phpunit.xml.dist
复制到 phpunit.xml
并根据您的需求进行修改,或者保持不变。运行PhpUnit 测试或composer脚本如下
$ composer test # or $ vendor/bin/phpunit