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-10-29 05:10:31 UTC
README
This package was destilled from legacy code!
You better do not want it to use this in production.
Installation
$ composer require germania-kg/prices
MySQL: This package requires a MySQL table germania_prices which you can install using germania_prices.sql
in sql/
directory.
Usage
PdoPrices is a Callable for retrieving prices for any given article ID. It implements the container-interop (upcoming PSR 11 standard).
<?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 ); ?>
Development
$ git clone https://github.com/GermaniaKG/Prices.git
$ cd Prices
$ composer install
Unit tests
Either copy phpunit.xml.dist
to phpunit.xml
and adapt to your needs, or leave as is. Run PhpUnit test or composer scripts like this:
$ composer test # or $ vendor/bin/phpunit