https://github.com/tarique-iqbal/promotional-campaign
Promotional Campaigns to give discounts
https://github.com/tarique-iqbal/promotional-campaign
clean-code dependency-container dependency-injection factory-pattern php82 pimple rules-engine solid
Last synced: 5 months ago
JSON representation
Promotional Campaigns to give discounts
- Host: GitHub
- URL: https://github.com/tarique-iqbal/promotional-campaign
- Owner: tarique-iqbal
- Created: 2024-07-05T11:05:09.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-11-29T16:27:30.000Z (6 months ago)
- Last Synced: 2024-11-29T17:29:36.660Z (6 months ago)
- Topics: clean-code, dependency-container, dependency-injection, factory-pattern, php82, pimple, rules-engine, solid
- Language: PHP
- Homepage:
- Size: 42 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Promotional Campaigns
A small command-line utility to apply certain promotional campaigns to give discounts. The system needs to be flexible regarding the promotional rules.| Product code | Name | Price |
|--------------|---------------|---------|
| 001 | Curry Sauce | 1.95 € |
| 002 | Pizza | 5.99 € |
| 003 | Men’s T-Shirt | 25.00 € |
- If you spend over €30, you get 10% off your purchase.
- If you buy 2 or more pizzas, the price for each drops to €3.99.| Items in basket | Total price |
|----------------------|-------------|
| 002,001,002,003 | 31.44 € || How it works? | |
|----------------------|-------------|
| 5.99+1.95+5.99+25.00 | = 38.93 |
| 38.93−(5.99−3.99)×2 | = 34.93 |
| 34.93−(34.93×10)÷100 | = 31.437 |
| round(31.437, 2) | = 31.44 |## Test Cases
| Items in basket | Total price |
|-----------------|-------------|
| 001,002,003 | 29.65 € |
| 002,001,002 | 9.93 € |
| 002,001,002,003 | 31.44 € |## Prerequisites
```
composer
php (>=8.2)
```## Installation and Run the script
- All the `code` required to get started
- Need write permission to following `directory``./var/logs`
- Install the script
```shell
$ cd /path/to/base/directory
$ composer install --no-dev
```- Run the script and sample output
```shell
$ php index.php
€31.44
```## Running the tests
- Follow Install instructions.
Adapt `phpunit.xml.dist` PHP Constant according to your setup environment.```shell
$ cd /path/to/base/directory
$ composer update
$ ./vendor/bin/phpunit tests
```Test-cases, test unit and integration tests.