<commit_before><?php

namespace Respect\Validation\Rules;

class Cpf extends AbstractRule 
{

    public function validate($input) 
    {

        $input = preg_replace('([^0-9])', '', $input);

        if (strlen($input) != 11)
            return false;
        
        if ($this->isSequenceOfNumber($input))
            return false;
        
        if ($this->processNumber($input))
            return true;
        
        return false;
    }
    
    private function processNumber($input)
    {
        $verify = array('firstDigit' => 0, 'secondDigit' => 0);

        $multiple = 10;

        for ($i = 0; $i < 9; $i++)
            $verify['firstDigit'] += ($multiple-- * (int) $input[$i]);

        $verify['firstDigit'] = 11 - ($verify['firstDigit'] % 11);

        if ($verify['firstDigit'] >= 10)
            $verify['firstDigit'] = 0;

        $multiple = 11;

        for ($i = 0; $i < 9; $i++)
            $verify['secondDigit'] += ($multiple-- * (int) $input[$i]);

        $verify['secondDigit'] += (2 * $verify['firstDigit']);
        $verify['secondDigit'] = 11 - ($verify['secondDigit'] % 11);

        if ($verify['secondDigit'] >= 10)
            $verify['secondDigit'] = 0;

        $digits = substr($input, (strlen($input) - 2), 2);

        if (strcmp("{$verify['firstDigit']}{$verify['secondDigit']}", $digits) === 0)
            return true;

        return false;
    }
   
    private function isSequenceOfNumber($input) 
    {   
        for ($i = 0; $i <= 9; $i++)
            if (strcmp($input, str_pad('', strlen($input), $i)) === 0)
                return true;
        
        return false;
    }

}<commit_msg>Simplified the CpfValidator<commit_after><?php

namespace Respect\Validation\Rules;

class Cpf extends AbstractRule 
{

    public function validate($input) 
    {
        $input = preg_replace('[^0-9]', '', $input);
        if (strlen($input) != 11)
            return false;
        if ($this->isSequenceOfNumber($input))
            return false;
        return $this->processNumber($input);
    }

    private function processNumber($input)
    {
        $multiple = 10;
        $firstDigit = $secondDigit = 0;

        for ($i = 0; $i < 9; $i++)
            $firstDigit += ($multiple-- * (int) $input[$i]);

        $firstDigit = 11 - ($firstDigit % 11);
        $firstDigit >= 10 && $firstDigit = 0;

        $multiple = 11;

        for ($i = 0; $i < 9; $i++)
            $secondDigit += ($multiple-- * (int) $input[$i]);

        $secondDigit += (2 * $firstDigit);
        $secondDigit = 11 - ($secondDigit % 11);

        $secondDigit >= 10 && $secondDigit = 0;
        $digits = substr($input, -2);

        return ("{$firstDigit}{$secondDigit}" === $digits);
    }

    private function isSequenceOfNumber($input) 
    {   
        for ($i = 0; $i <= 9; $i++)
            if ($input === str_repeat($i, 11))
                return true;
        return false;
    }

}
{'fraction_non_alphanumeric': 0.1788034188034188, 'fraction_numerical': 0.023247863247863248, 'mean_word_length': 1.982670744138634, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2387750', 'n_tokens_mistral': 993, 'n_tokens_neox': 905, 'n_words': 211}