src/Money.php
public static function of($amount, $currency, Context $context = null, int $roundingMode = RoundingMode::UNNECESSARY) : Money
    {
        if (! $currency instanceof Currency) {
            $currency = Currency::of($currency);
        }

        if ($context === null) {
            $context = new DefaultContext();
        }

        $amount = BigNumber::of($amount);

        return self::create($amount, $currency, $context, $roundingMode);
    }
public static function of($amount, $currency, Context $context = null, int $roundingMode = RoundingMode::UNNECESSARY) : Money
    {
        if (! $currency instanceof Currency) {
            $currency = Currency::of($currency);
        }

        if ($context === null) {
            $context = new DefaultContext();
        }

        $amount = BigNumber::of($amount);

        return self::create($amount, $currency, $context, $roundingMode);
    }
public static function of ( $ amount , $ currency , Context $ context = null , int $ roundingMode = RoundingMode :: UNNECESSARY ) : Money { if ( ! $ currency instanceof Currency ) { $ currency = Currency :: of ( $ currency ) ; } if ( $ context === null ) { $ context = new DefaultContext ( ) ; } $ amount = BigNumber :: of ( $ amount ) ; return self :: create ( $ amount , $ currency , $ context , $ roundingMode ) ; }
Returns a Money of the given amount and currency.

By default, the money is created with a DefaultContext. This means that the amount is scaled to match the
currency's default fraction digits. For example, `Money::of('2.5', 'USD')` will yield `USD 2.50`.
If the amount cannot be safely converted to this scale, an exception is thrown.

To override this behaviour, a Context instance can be provided.
Operations on this Money return a Money with the same context.

@param BigNumber|number|string $amount       The monetary amount.
@param Currency|string|int     $currency     The Currency instance, ISO currency code or ISO numeric currency code.
@param Context|null            $context      An optional Context.
@param int                     $roundingMode An optional RoundingMode, if the amount does not fit the context.

@return Money

@throws NumberFormatException      If the amount is a string in a non-supported format.
@throws RoundingNecessaryException If the rounding was necessary to represent the amount at the requested scale.
Returns a Money of the given amount and currency .