You are here

public function MobileNumber::checkFlood in Mobile Number 7

Checks whether there were too many verifications attempted with the current number.

Parameters

string $type: Type of flood check, can be either 'sms' or 'verification'.

Return value

bool FALSE for too many attempts on this mobile number, TRUE otherwise.

Overrides MobileNumberInterface::checkFlood

File

src/MobileNumber.php, line 187

Class

MobileNumber
Class MobileNumber handles mobile number validation and verification.

Code

public function checkFlood($type = 'verification') {
  switch ($type) {
    case 'verification':
      return flood_is_allowed('mobile_number_verification', $this::VERIFY_ATTEMPTS_COUNT, $this::VERIFY_ATTEMPTS_INTERVAL, $this->callableNumber);
    case 'sms':
      return flood_is_allowed('mobile_number_sms', $this::SMS_ATTEMPTS_COUNT, $this::SMS_ATTEMPTS_INTERVAL, $this->callableNumber) && flood_is_allowed('mobile_number_sms_ip', $this::SMS_ATTEMPTS_COUNT * 5, $this::SMS_ATTEMPTS_INTERVAL * 5);
    default:
      return TRUE;
  }
}