- Docker
- Makefile (optional)
- PHP 8.2
- Composer 2
- PHP Extensions: dom, mbstring, curl & zip (to make composer faster)
make start
or
docker compose up -d
docker compose run php composer install
use Bartosz\CurrencyExchanger\Currency;
use Bartosz\CurrencyExchanger\Money;
use Bartosz\CurrencyExchanger\ExchangeCurrencyFacade;
use Bartosz\CurrencyExchanger\WithPurchaseFeeCalculator;
use Bartosz\CurrencyExchanger\WithSalesFeeCalculator;
$facade = new ExchangeCurrencyFacade(
new WithPurchaseFeeCalculator(),
new WithSalesFeeCalculator(),
);
// 100 euro -> new Money(10000, Currency::EUR)
// All values are represented as the fractional unit/subunit to avoid rounding issues
$facade->purchase(new Money(10000, Currency::EUR), Currency::GBP);
$facade->sell(new Money(10000, Currency::EUR), Currency::GBP);
To run all
make qc
or
make test
make phpstan
make phpcs
- Core domain
- Calculates a value of exchange with additional strategies that apply fees depending on conditions
- Application Layer / Facade
- Encapsulates business logic and provides a friendly API for interaction
- Define use cases or application services for specific actions
- Infrastructure Layer
- Implement repository interfaces defined in the domain layer
- Expose HTTP or CLI interfaces for interacting with the business logic