Return the score for repeated characters.

@return integer
438306
protected function _calculateRepeatTokenScore()
    {
        $score = 0;
        $repeats = 0;

        foreach ($this->_tokens as $tokenCount) {
            if ($tokenCount > 1) {
                $repeats += $tokenCount - 1;
            }
        }

        if ($repeats > 0) {
            $score -= (int) ($repeats / ($this->_length - $repeats)) + 1;
        }

        return $score;
    }
993924
public static function gerar()
    {
        $cpf = array ();
        for ($i = 0; $i < 9; $i++) {
            $cpf[$i] = rand(0, 9);
        }

        // Primeiro dígito
        $soma = 0;
        for ($i = 0; $i < 9; $i++) {
            $soma += ((10 - $i) * $cpf[$i]);
        }
        $d1 = 11 - ($soma % 11);
        if ($d1 >= 10) {
            $d1 = 0;
        }
        $cpf[9] = $d1;

        // Segundo Dígito
        $soma = 0;
        for ($i = 0; $i < 10; $i++) {
            $soma += ((11 - $i) * $cpf[$i]);
        }
        $d2 = 11 - ($soma % 11);
        if ($d2 >= 10) {
            $d2 = 0;
        }
        $cpf[10] = $d2;

        return static::formatar(implode("", $cpf));
    }
230034
private function getWinner()
    {
        foreach ($this->winningValues() as $values) {
            // skip for empty cells
            if (count(array_unique($values)) == 1 && empty(end($values))) {
                continue;
            }

            //hooray we have a winner
            if (count(array_unique($values)) == 1) {
                $winner = array_unique($values);
                return array_shift($winner);
            }
        }

        return false;
    }
492213
public function getLineNumber(){
		if( $this->index ){
			// https://bugs.php.net/bug.php?id=49790
			if (ini_get("mbstring.func_overload")) {
				return substr_count(substr($this->input, 0, $this->index), "\n") + 1;
			} else {
				return substr_count($this->input, "\n", 0, $this->index) + 1;
			}
		}
		return 1;
	}
1292919
public function getEntropy()
    {
        if ('qwerty' === $this->graph || 'dvorak' === $this->graph) {
            $startingPos = $this->keyboardStartingPos;
            $avgDegree = $this->keyboardAvgDegree;
        } else {
            $startingPos = $this->keypadStartingPos;
            $avgDegree = $this->keypadAvgDegree;
        }

        $possibilities = 0;
        // estimate the number of possible patterns w/ token length or less with match turns or less.
        $tokenLength = strlen($this->token);
        for ($i = 2; $i <= $tokenLength; ++$i) {
            $possibleTurns = min($this->turns, $i - 1);

            for ($j = 1; $j <= $possibleTurns; ++$j) {
                $possibilities += $this->binom($i - 1, $j - 1) * $startingPos * ($avgDegree ** $j);
            }
        }
        $entropy = $this->log($possibilities);

        // add extra entropy for shifted keys. (% instead of 5, A instead of a.)
        if (!empty($this->shiftedCount)) {
            $possibilities = 0;
            $unshiftedCount = strlen($this->token) - $this->shiftedCount;
            $len = min($this->shiftedCount, $unshiftedCount);

            for ($i = 0; $i <= $len; ++$i) {
                $possibilities += $this->binom($this->shiftedCount + $unshiftedCount, $i);
            }
            $entropy += $this->log($possibilities);
        }

        return $entropy;
    }
1128352
public function scoreResult()
    {
        $result = false;

        if($this->sessionSecret)
        {
            $fields = array(
                'session_secret' => urlencode($this->sessionSecret),
                'scoring_key'    => $this->scoringKey
            );

            $resp = $this->doHttpsPostReturnJSONArray($this->webService, '/ws/scoreGame', $fields);

            if($resp) {
                $result = ($resp->status_code == 1);
            }
        }

        return $result;
    }
1129027
public function getTotal()
    {
        return $this->score->getValid() + $this->score->getPartial() + $this->score->getNotValid();
    }
436110
public function similarity($text1, $text2)
    {
        if($text1 === $text2) {
            return 1.0;
        }
        
        // ensure that s1 is shorter than or same length as s2
        if (strlen($text1) > strlen($text2)) {
            $tmp = $text1;
            $text1 = $text2;
            $text2 = $tmp;
        }

        $strLen1 = strlen($text1);
        $strLen2 = strlen($text2);
        
        $maxDistance = (int)$strLen2 / 2;
        $commonCounter = 0; // count of common characters
        $transpositionCounter = 0; // count of transpositions
        $prevPosition = -1;
        for ($index = 0; $index < $strLen1; $index++) 
        {
            $char = $text1[$index];
            // init inner loop 
            $jindex = max(0, $index - $maxDistance);
            while($jindex < min($strLen2, $index + $maxDistance))
            {
                if ($char === $text2[$jindex]) {
                    $commonCounter++; // common char found
                    if ($prevPosition != -1 && $jindex < $prevPosition) {
                        $transpositionCounter++; 
                    }
                  $prevPosition = $jindex;
                  break;
                }
                
                $jindex++;
            }
        }
        // no common characters between strings
        if($commonCounter === 0) {
            return 0.0;
        }
        
        // first compute the score
        $score = (
                ($commonCounter / $strLen1) +
                ($commonCounter / $strLen2) +
               (($commonCounter - $transpositionCounter) / $commonCounter)) / 3.0;

        //init values
        $prefixLength = 0; // length of prefix
        $last = min($this->minPrefixLength, $strLen1);        
        while($prefixLength < $last && $text1[$prefixLength] == $text2[$prefixLength])
        {
            $prefixLength++;
        }
        
        return $score + (($prefixLength * (1 - $score)) / 10);     
    }
1100639
public function daleChallReadabilityScore($strText = false)
    {
        $strText = $this->setText($strText);

        $score = Maths::bcCalc(
            Maths::bcCalc(
                0.1579,
                '*',
                Maths::bcCalc(
                    100,
                    '*',
                    Maths::bcCalc(
                        $this->daleChallDifficultWordCount($strText),
                        '/',
                        Text::wordCount($strText, $this->strEncoding)
                    )
                )
            ),
            '+',
            Maths::bcCalc(
                0.0496,
                '*',
                Maths::bcCalc(
                    Text::wordCount($strText, $this->strEncoding),
                    '/',
                    Text::sentenceCount($strText, $this->strEncoding)
                )
            )
        );

        if ($this->normalise) {
            return Maths::normaliseScore($score, 0, 10, $this->dps);
        } else {
            return Maths::bcCalc($score, '+', 0, true, $this->dps);
        }
    }
774486
public function getNextCharacter()
	{
		$next = next($this->characters);
		
		if ($next === false && $this->chunker->hasNextChunk()) {
			$this->read($this->chunker->getNextChunk());
			$next = reset($this->characters);
		}
		
		return $next;
	}
597876
public static function get()
    {
        mt_srand((int) (microtime(true) * 1000));

        $b = md5(uniqid(mt_rand(), true), true);
        $b[6] = chr((ord($b[6]) & 0x0F) | 0x40);
        $b[8] = chr((ord($b[8]) & 0x3F) | 0x80);

        return implode('-', unpack('H8a/H4b/H4c/H4d/H12e', $b));
    }
84932
protected function _calculateSymbolScore()
    {
        $score = 0;
        $symbolCount = $this->_getClassCount(self::CLASS_SYMBOL);

        if ($symbolCount > 0) {
            $score += $symbolCount * 6;
        }

        return $score;
    }
147649
public static function charAsciiAlphaUpperArray()
    {
        static $result = array();

        if (!$result) {
            for ($i = 65; $i < 91; ++$i) {
                $result[] = \chr($i);
            }
        }

        return $result;
    }
626396
public function getHelpfulness()
    {
        if ($this->hits + $this->misses === 0) {
            return 0.00;
        }

        return number_format(($this->hits / ($this->hits + $this->misses)) * 100, 2);
    }
706188
protected function getRandomStr()
    {
        $str = '';
        $strPol = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
        $max = strlen($strPol) - 1;
        for ($i = 0; $i < 16; $i++) {
            $str .= $strPol[mt_rand(0, $max)];
        }
        return $str;
    }
797122
public function getCharacterApi()
    {
        if (!$this->apis->has('character')) {
            $this->apis->set('character', new Character($this));
        }

        return $this->apis->get('character');
    }
351550
public function getUniqueFolderName()
    {
        return sprintf(
            '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
            mt_rand(0, 65535),
            mt_rand(0, 65535),
            mt_rand(0, 65535),
            mt_rand(0, 4095) | 0x4000,
            mt_rand(0, 0x3fff) | 0x8000,
            mt_rand(0, 65535),
            mt_rand(0, 65535),
            mt_rand(0, 65535)
        );
    }