Passed
Push — master ( 004729...b97da3 )
by Tim
02:36
created

Random   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 4
dl 0
loc 13
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateOneTimePassword() 0 6 1
1
<?php
2
3
/**
4
 * Random utilities for SMS-based OTP.
5
 *
6
 * @package tvdijen/simplesamlphp-module-cmdotcom
7
 */
8
9
declare(strict_types=1);
10
11
namespace SimpleSAML\Module\cmdotcom\Utils;
12
13
class Random
14
{
15
    /**
16
     * Generate a 6-digit random code
17
     *
18
     * @return string
19
     */
20
    public function generateOneTimePassword(): string
21
    {
22
        $code = sprintf("%06d", mt_rand(10000, 999999));
23
        $padded = str_pad($code, 6, '0', STR_PAD_LEFT);
24
25
        return $padded;
26
    }
27
}
28