private function generateCode($codePattern) { if (empty($codePattern)) { return strtoupper(substr(uniqid('', true
), 6, 8
));
} $codePattern =
$this->
replaceAllMatchingPatterns($codePattern,
range('A', 'Z'
), '%s'
);
$codePattern =
$this->
replaceAllMatchingPatterns($codePattern,
range('0', '9'
), '%d'
);
return $codePattern;
} /**
* validates the code pattern
*/
private function validateCodePattern(string
$codePattern, int
$numberOfUnits): bool
{ $numberOfStringValues =
substr_count($codePattern, '%s'
);