library/Money/MoneyTrait.php
public function fromFloat($amount, $currency = null)
    {
        if ($currency) {
            $this->setCurrency($currency);
        }

        if (!is_float($amount)) {
            throw new InvalidArgumentException(sprintf(
                'Amount must be a float, %s given',
                gettype($amount)
            ));
        }
        
        $this->amount = $this->toInt(
            round(
                $this->getSubUnit() * round($amount, $this->getFractionDigits(), PHP_ROUND_HALF_UP),
                0,
                PHP_ROUND_HALF_UP
            )
        );
        return $this;
    }
public function fromFloat($amount, $currency = null)
    {
        if ($currency) {
            $this->setCurrency($currency);
        }

        if (!is_float($amount)) {
            throw new InvalidArgumentException(sprintf(
                'Amount must be a float, %s given',
                gettype($amount)
            ));
        }
        
        $this->amount = $this->toInt(
            round(
                $this->getSubUnit() * round($amount, $this->getFractionDigits(), PHP_ROUND_HALF_UP),
                0,
                PHP_ROUND_HALF_UP
            )
        );
        return $this;
    }
public function fromFloat ( $ amount , $ currency = null ) { if ( $ currency ) { $ this -> setCurrency ( $ currency ) ; } if ( ! is_float ( $ amount ) ) { throw new InvalidArgumentException ( sprintf ( 'Amount must be a float, %s given' , gettype ( $ amount ) ) ) ; } $ this -> amount = $ this -> toInt ( round ( $ this -> getSubUnit ( ) * round ( $ amount , $ this -> getFractionDigits ( ) , PHP_ROUND_HALF_UP ) , 0 , PHP_ROUND_HALF_UP ) ) ; return $ this ; }
Populate current amount from a given float value

@param float $amount
@param string $currency
@return $this
Populate current amount from a given float value