Exemplo n.º 1
0
 /**
  * @param int $codeLength
  * @param array $generatedCoupons
  *
  * @return string
  */
 protected function generateUniqueCode($codeLength, array $generatedCoupons)
 {
     Assert::nullOrRange($codeLength, 1, 40, 'Invalid %d code length should be between %d and %d');
     do {
         $hash = sha1(microtime(true));
         $code = strtoupper(substr($hash, 0, $codeLength));
     } while ($this->isUsedCode($code, $generatedCoupons));
     return $code;
 }