src/Money.php
public function divide($operand, $roundingMode = self::ROUND_HALF_UP, $useGaapPrecision = false)
    {
        $this->assertOperand($operand, true);

        $validatedOperand = $this->normalizeOperand($operand);

        if ($useGaapPrecision) {
            $amount = Math::bcround(
                bcdiv($this->amount, $validatedOperand, self::GAAP_PRECISION + 1),
                self::GAAP_PRECISION,
                $roundingMode
            );
        } else {
            $amount = Math::bcround(
                bcdiv($this->amount, $validatedOperand, self::GAAP_PRECISION + 1),
                self::BASIC_PRECISION,
                $roundingMode
            );
        }

        return new Money($amount, $this->currency);
    }
public function divide($operand, $roundingMode = self::ROUND_HALF_UP, $useGaapPrecision = false)
    {
        $this->assertOperand($operand, true);

        $validatedOperand = $this->normalizeOperand($operand);

        if ($useGaapPrecision) {
            $amount = Math::bcround(
                bcdiv($this->amount, $validatedOperand, self::GAAP_PRECISION + 1),
                self::GAAP_PRECISION,
                $roundingMode
            );
        } else {
            $amount = Math::bcround(
                bcdiv($this->amount, $validatedOperand, self::GAAP_PRECISION + 1),
                self::BASIC_PRECISION,
                $roundingMode
            );
        }

        return new Money($amount, $this->currency);
    }
public function divide ( $ operand , $ roundingMode = self :: ROUND_HALF_UP , $ useGaapPrecision = false ) { $ this -> assertOperand ( $ operand , true ) ; $ validatedOperand = $ this -> normalizeOperand ( $ operand ) ; if ( $ useGaapPrecision ) { $ amount = Math :: bcround ( bcdiv ( $ this -> amount , $ validatedOperand , self :: GAAP_PRECISION + 1 ) , self :: GAAP_PRECISION , $ roundingMode ) ; } else { $ amount = Math :: bcround ( bcdiv ( $ this -> amount , $ validatedOperand , self :: GAAP_PRECISION + 1 ) , self :: BASIC_PRECISION , $ roundingMode ) ; } return new Money ( $ amount , $ this -> currency ) ; }
Division compatible with Verraes' Money
To use GAAP precision rounding, pass true as third argument

@param      $operand
@param int  $roundingMode
@param bool $useGaapPrecision

@return \Keios\MoneyRight\Money
@throws \Keios\MoneyRight\Exceptions\InvalidArgumentException
Division compatible with Verraes Money To use GAAP precision rounding pass true as third argument