Skip to content

Latest commit

 

History

History
51 lines (34 loc) · 1.53 KB

Money.md

File metadata and controls

51 lines (34 loc) · 1.53 KB

Do you like this library? Leave a ★ or run composer global require symfony/thanks && composer thanks to say thank you to all libraries you use in your current project, this included!

Money Complex Value Object

Represents a monetary value.

Extends moneyphp/money.

Base Money signature

// vendor/moneyphp/money/src/Money.php

/**
 * @param  integer                $amount
 * @param  \Money\Currency|string $currency
 * @throws \Money\InvalidArgumentException
 */
public function __construct($amount, $currency)

How to use the object

See the working example: examples/Currency.php.

use SerendipityHQ\Component\ValueObjects\Money\Money;

$values = [
    Money::HUMAN_AMOUNT => 300,
    Money::CURRENCY => 'EUR'
];

$money = new Money($values);
dump($money);

NOTES

This object is a wrapper for the Money object by PHPMoney.

As the original object is a final class, it is not possible to extend it.

So this ValueObjects\Money object simply wraps an \Money\Money object.

Do you like this library? Leave a ★ or run composer global require symfony/thanks && composer thanks to say thank you to all libraries you use in your current project, this included!