Conditions | 9 |
Paths | 6 |
Total Lines | 24 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 9 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | 15 | public static function funcBase($number, $radix, $minLength = null) |
|
25 | { |
||
26 | try { |
||
27 | 15 | $number = (int) Helpers::validateNumericNullBool($number); |
|
28 | 14 | $radix = (int) Helpers::validateNumericNullBool($radix); |
|
29 | 2 | } catch (Exception $e) { |
|
30 | 2 | return $e->getMessage(); |
|
31 | } |
||
32 | 13 | $minLength = Functions::flattenSingleValue($minLength); |
|
33 | |||
34 | 13 | if ($minLength === null || is_numeric($minLength)) { |
|
35 | 11 | if ($number < 0 || $number >= 2 ** 53 || $radix < 2 || $radix > 36) { |
|
36 | 4 | return Functions::NAN(); // Numeric range constraints |
|
37 | } |
||
38 | |||
39 | 7 | $outcome = strtoupper((string) base_convert($number, 10, $radix)); |
|
40 | 7 | if ($minLength !== null) { |
|
41 | 3 | $outcome = str_pad($outcome, (int) $minLength, '0', STR_PAD_LEFT); // String padding |
|
42 | } |
||
43 | |||
44 | 7 | return $outcome; |
|
45 | } |
||
46 | |||
47 | 2 | return Functions::VALUE(); |
|
48 | } |
||
50 |