Eu uso essa função php abaixo, é uma forma bem enxuta de validar. Está legível? não, fica muito difícil dar manutenção, mas acerdito que uma validação desse tipo raramente vai mudar, e se mudar é mais facil simplesmente refazer.
Consegui essa validação de algum repositório publico aleatório a mais de 8 anos atrás e nunca tive problemas
public function validate(string $attribute, mixed $value, Closure $fail): void
{
$c = preg_replace('/\D/', '', $value);
if (strlen($c) != 11 || preg_match("/^{$c[0]}{11}$/", $c)) return false;
for ($s = 10, $n = 0, $i = 0; $s >= 2; $n += $c[$i++] * $s--);
if ($c[9] != ((($n %= 11) < 2) ? 0 : 11 - $n)) return false;
for ($s = 11, $n = 0, $i = 0; $s >= 2; $n += $c[$i++] * $s--);
if ($c[10] != ((($n %= 11) < 2) ? 0 : 11 - $n)) return false
}