Factorial::factorialize()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 1
crap 3
1
<?php
2
3
namespace Vehsamrak\Factorial;
4
5
/**
6
 * @author Vehsamrak
7
 */
8
class Factorial
9
{
10
11 17
    public function factorialize(int $integer): int
12
    {
13 17
        if ($integer < 0) {
14 10
            throw new \InvalidArgumentException('Negative number can not be processed!');
15
        }
16
17 7
        $factorial = 1;
18
19 7
        for ($i = 1; $i <= $integer; $i++) {
20 6
            $factorial *= $i;
21
        };
22
23 7
        return $factorial;
24
    }
25
}
26