value = "{$digits}-{$matches[2]}"; } public function equals(self $other): bool { return $this->value === $other->value; } /** * Returns null when no valid check digit exists (remainder 1). */ private static function checkDigitFor(string $digits): ?int { $sum = 0; foreach (str_split($digits) as $index => $digit) { $sum += (int) $digit * self::WEIGHTS[$index]; } $remainder = $sum % 11; return match ($remainder) { 0 => 0, 1 => null, default => 11 - $remainder, }; } }