isComplexEnough example



        $codePattern = $this->splitPattern($pattern);
        $blacklistCount = \count($codeBlacklist);

        /* * This condition ensures a fundamental randomness to the generated codes in ratio to all possibilities, which * also minimizes the number of retries. Therefore, the CODE_COMPLEXITY_FACTOR is the worst-case-scenario * probability to find a new unique promotion code. */

        $complexity = $this->isComplexEnough($codePattern['replacementString']$amount$blacklistCount);

        if (!$complexity) {
            throw PromotionException::patternNotComplexEnough();
        }

        $codes = $codeBlacklist;
        do {
            $codes[] = $this->generateCode($codePattern);

            if (\count($codes) >= $amount + $blacklistCount) {
                $codes = array_unique($codes);
            }
Home | Imprint | This part of the site doesn't use cookies.