Documentation

MoneyFactory implements IMoneyFactory

A factory for creating IMoney instances

Table of Contents

$supplier Money supplier. Closure
__construct() Create a new MoneyFactory instance mixed
getMoney() Retrieve a new IMoney instance of a certain amount. IMoney

Properties

$supplier

Money supplier.

private Closure $supplier
f( string $amount ) : IMoney

Methods

__construct()

Create a new MoneyFactory instance

public __construct( $moneySupplier : Closure ) : mixed
Parameters
$moneySupplier : Closure

f( string $amount ) : IMoney

Return values
mixed

getMoney()

Retrieve a new IMoney instance of a certain amount.

public getMoney( $amount : string ) : IMoney

This expects $amount to be in cents or the smallest currency unit. If a decimal point '.' is encountered, the amount is multiplied by 100 before creating the Money object. This expects a scale of 2 and any additional digits are rounded off.

Parameters
$amount : string

Amount

Return values
IMoney

Money

Search results