You are here

public static function MobileNumber::generateVerificationCode in Mobile Number 7

Generates a random numeric string.

Parameters

int $length: Number of digits.

Return value

string Code in length of $length.

Overrides MobileNumberInterface::generateVerificationCode

4 calls to MobileNumber::generateVerificationCode()
MobileNumberClassTestCase::testFunctions in tests/mobile_number.class.test
Test functions.
MobileNumberElementTestCase::testTfa in tests/mobile_number.element.test
Test tfa option.
MobileNumberElementTestCase::testVerification in tests/mobile_number.element.test
Test number verification.
MobileNumberFieldTestCase::createMobileNumberNode in tests/mobile_number.field.test
Create node with mobile number(s).

File

src/MobileNumber.php, line 180

Class

MobileNumber
Class MobileNumber handles mobile number validation and verification.

Code

public static function generateVerificationCode($length = 4) {
  return str_pad((string) rand(0, pow(10, $length)), $length, '0', STR_PAD_LEFT);
}