Failed Conditions
Pull Request — master (#47)
by Jordan
22:22 queued 18:21
created

PolyfillProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 21
ccs 0
cts 10
cp 0
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A randomInt() 0 12 2
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
}