feriatos/sigma-test-task
Composer 安装命令:
composer require feriatos/sigma-test-task
包简介
Test task for Sigma Software
README 文档
README
This library allows to create a POS Terminal and count a price for a shopping cart depending on different pricing strategies.
How to install
composer require "feriatos/sigma-test-task:*"
How to use
First create pricing strategies and add products:
$pricing = new OneTierPricing(); $pricing->addProduct(new OneTierProduct('ZA', 2, 7, 4)); $pricing->addProduct(new OneTierProduct('YB', 12)); $pricing->addProduct(new OneTierProduct('FC', 1.25, 6, 6)); $pricing->addProduct(new OneTierProduct('GD', 0.15));
Then create a terminal and set pricing:
$terminal = new POSTerminal(); $terminal->setPricing($pricing);
Scan items:
$terminal->scanItem('ZA'); $terminal->scanItem('YB'); $terminal->scanItem('FC'); $terminal->scanItem('GD'); $terminal->scanItem('ZA'); $terminal->scanItem('YB'); $terminal->scanItem('ZA'); $terminal->scanItem('ZA');
And get a result:
$totalPrice = $terminal->getTotal();
To clean items call:
$terminal->resetItems();
How to extend
This library utilizes Strategy design patter. You could extend it just implementing
PricingInterface and ProductInterface and add your own pricing strategy (for
example two or three tiers pricing strategy).
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-17