Passed
Push — master ( 49220f...d02965 )
by BENOIT
04:43 queued 02:28
created

string_combinations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 4
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace BenTools\StringCombinations;
4
5
require_once __DIR__ . '/StringCombinations.php';
6
7
/**
8
 * @param $charset
9
 * @param int      $min
10
 * @param int|null $max
11
 * @param string   $glue
12
 * @return StringCombinations
13
 */
14
function string_combinations($charset, $min = 1, $max = null, $glue = '')
15
{
16
    return new StringCombinations($charset, $min, $max, $glue);
17
}
18
19
/**
20
 * @param $number
21
 * @return float|int
22
 */
23
function fact($number)
24
{
25
    if (extension_loaded('gmp')) {
26
        return gmp_intval(gmp_fact($number));
27
    }
28
    for ($x = $number, $factorial = 1; $x >= 1; $x--) {
29
        $factorial = $factorial * $x;
30
    }
31
    return $factorial;
32
}
33
34
35
function random_int($min, $max)
36
{
37
    static $callable;
38
    $callable = function_exists('random_int') ? 'random_int' : 'mt_rand';
39
    return $callable($min, $max);
40
}
41