baskof147/discount_calculator

此包的最新版本(1.2)没有可用的许可证信息。

1.2 2020-10-18 16:13 UTC

This package is not auto-updated.

Last update: 2024-10-01 04:51:32 UTC


README

单产品单折扣

use baskof147\discount_calculator\calculator\DiscountCalculator;
use baskof147\discount_calculator\product\Product;
use baskof147\discount_calculator\product\ProductCollection;
use baskof147\discount_calculator\discount\StaticDiscount;
use baskof147\discount_calculator\discount\DiscountCollection;

$productCollection = new ProductCollection();
$productCollection->setProduct(new Product('A', 550));

$discountCollection = new DiscountCollection();
$discountCollection->setDiscount(new StaticDiscount(10));

$store = new DiscountCalculator($productCollection, $discountCollection);
return $store->getTotalPriceWithDiscount();

多产品多折扣

use baskof147\discount_calculator\calculator\DiscountCalculator;
use baskof147\discount_calculator\product\Product;
use baskof147\discount_calculator\product\ProductCollection;
use baskof147\discount_calculator\discount\StaticDiscount;
use baskof147\discount_calculator\discount\DiscountCollection;

$products = [
    new Product('A', 550),
    new Product('B', 330),
    new Product('C', 1100, 3)
];
$productCollection = new ProductCollection($products);

$discounts = [
    new StaticDiscount(10)
];
$discountCollection = new DiscountCollection($discounts);

$store = new DiscountCalculator($productCollection, $discountCollection);
return $store->getTotalPriceWithDiscount();

Psalm

vendor/bin/psalm

测试

vendor/bin/codecept run