PHP code example of lukeraymonddowning / pest-plugin-money

1. Go to this page and download the library: Download lukeraymonddowning/pest-plugin-money library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lukeraymonddowning / pest-plugin-money example snippets


expect(Money::of(100, "GBP"))->toBeMoney();
expect("Hello World")->not->toBeMoney();

expect(Money::of(150, "GBP"))->toCost(150, 'GBP');
expect(Money::of(150, "GBP"))->toCost($anotherMoneyObject);
expect(Money::of(150, "GBP"))->not->toCost(100, 'GBP');

expect(Money::of(150, "GBP"))->toCostLessThan(160, 'GBP');
expect(Money::of(150, "GBP"))->toCostLessThan($anotherMoneyObject);
expect(Money::of(150, "GBP"))->not->toCostLessThan(140, 'GBP');

expect(Money::of(150, "GBP"))->toCostMoreThan(140, 'GBP');
expect(Money::of(150, "GBP"))->toCostMoreThan($anotherMoneyObject);
expect(Money::of(150, "GBP"))->not->toCostMoreThan(160, 'GBP');

useMoneyLibrary(\Money\Money::class); // Use the MoneyPHP library
useMoneyLibrary(\Brick\Money\Money::class); // Use the Brick Money library
useMoneyLibrary(\ArchTech\Money\Money::class); // Use the Archtech Money library

useCurrency('GBP'); 
expect($money)->toCost('100'); // Uses Great British Pounds

useCurrency('USD'); 
expect($money)->toCost('100'); // Uses US Dollars