protected function CouponCodeGenerator::getCharacterSet in Commerce Core 8.2
Gets the character set for the given pattern type.
Parameters
string $pattern_type: The pattern type.
Return value
string[] The character set.
2 calls to CouponCodeGenerator::getCharacterSet()
- CouponCodeGenerator::generateCodes in modules/
promotion/ src/ CouponCodeGenerator.php - Generates coupon codes.
- CouponCodeGenerator::validatePattern in modules/
promotion/ src/ CouponCodeGenerator.php - Validates the given pattern for the specified quantity.
File
- modules/
promotion/ src/ CouponCodeGenerator.php, line 78
Class
Namespace
Drupal\commerce_promotionCode
protected function getCharacterSet($pattern_type) {
$characters = [];
switch ($pattern_type) {
// No 'I', 'O', 'i', 'l', '0', '1' to avoid recognition issues.
case CouponCodePattern::ALPHANUMERIC:
$characters = [
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'J',
'K',
'L',
'M',
'N',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'j',
'k',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
];
break;
case CouponCodePattern::ALPHABETIC:
// No 'I', 'i', 'l' to avoid recognition issues.
$characters = [
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'j',
'k',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
];
break;
case CouponCodePattern::NUMERIC:
$characters = [
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
];
}
return $characters;
}