Conditions | 6 |
Paths | 7 |
Total Lines | 29 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
40 | public static function validate($cpf) |
||
41 | { |
||
42 | // Delete not Numbers || Elimina possivel mascara |
||
43 | $cpf = self::toDatabase($cpf); |
||
44 | |||
45 | // Verify Digit not can be 11 || Verifica se o numero de digitos informados é igual a 11 |
||
46 | if (strlen($cpf) != 11) { |
||
47 | return false; |
||
48 | } |
||
49 | |||
50 | // Block Black Cpf's |
||
51 | if (static::foundInFile($cpf, 'black-cpf')) { |
||
52 | return false; |
||
53 | } |
||
54 | |||
55 | // Verify if Cpf is Valid || Calcula os digitos verificadores para verificar se o |
||
56 | // CPF é válido |
||
57 | for ($t = 9; $t < 11; $t++) { |
||
58 | |||
59 | for ($d = 0, $c = 0; $c < $t; $c++) { |
||
60 | $d += $cpf{$c} * (($t + 1) - $c); |
||
61 | } |
||
62 | $d = ((10 * $d) % 11) % 10; |
||
63 | if ($cpf{$c} != $d) { |
||
64 | return false; |
||
65 | } |
||
66 | } |
||
67 | |||
68 | return true; |
||
69 | } |
||
84 |