| Total Complexity | 4 |
| Total Lines | 27 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | #[Attribute(Attribute::TARGET_PROPERTY)] |
||
| 10 | class DigitoVerificador extends AbstractValidation |
||
| 11 | { |
||
| 12 | public function __construct(?string $message = 'CPF inválido') |
||
| 13 | { |
||
| 14 | parent::__construct($message); |
||
| 15 | } |
||
| 16 | |||
| 17 | public function evaluate($input, array $context = []): bool |
||
| 18 | { |
||
| 19 | $numbers = preg_replace('/\D/', '', (string) $input); |
||
| 20 | $number = substr($numbers, 0, -1); |
||
| 21 | $digit = (int) substr($numbers, -1); |
||
| 22 | return self::mod11($number) === $digit; |
||
| 23 | } |
||
| 24 | |||
| 25 | public static function mod11($input): int |
||
| 36 | } |
||
| 37 | } |
||
| 38 |