Failed Conditions
Pull Request — master (#47)
by Jordan
07:14 queued 03:12
created

PolyfillProvider::randomInt()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
nc 2
nop 2
dl 0
loc 12
ccs 0
cts 10
cp 0
crap 6
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Samsara\Fermat\Provider;
4
5
use RandomLib\Factory;
6
7
class PolyfillProvider
8
{
9
10
    /**
11
     * @param $max
12
     * @param $min
13
     *
14
     * @return int
15
     */
16
    public static function randomInt(int $max, int $min): int
17
    {
18
19
        try {
20
            $num = random_int($min, $max);
21
        } catch (\Exception $exception) {
22
            $randFactory = new Factory();
23
            $generator = $randFactory->getMediumStrengthGenerator();
24
            $num = $generator->generateInt($min, $max);
25
        }
26
27
        return $num;
28
29
    }
30
31
}