Passed
Push — master ( c380b2...9239b3 )
by Adrien
10:06
created

Quotient::funcQuotient()   A

Complexity

Conditions 2
Paths 4

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 4
nop 2
dl 0
loc 11
ccs 7
cts 7
cp 1
crap 2
rs 10
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
4
5
use Exception;
6
7
class Quotient
8
{
9
    /**
10
     * QUOTIENT.
11
     *
12
     * QUOTIENT function returns the integer portion of a division. Numerator is the divided number
13
     *        and denominator is the divisor.
14
     *
15
     * Excel Function:
16
     *        QUOTIENT(value1,value2)
17
     *
18
     * @param mixed $numerator Expect float|int
19
     * @param mixed $denominator Expect float|int
20
     *
21
     * @return int|string
22
     */
23 13
    public static function funcQuotient($numerator, $denominator)
24
    {
25
        try {
26 13
            $numerator = Helpers::validateNumericNullSubstitution($numerator, 0);
27 12
            $denominator = Helpers::validateNumericNullSubstitution($denominator, 0);
28 11
            Helpers::validateNotZero($denominator);
29 5
        } catch (Exception $e) {
30 5
            return $e->getMessage();
31
        }
32
33 8
        return (int) ($numerator / $denominator);
34
    }
35
}
36