Skip to content

Commit 748e64d

Browse files
committed
simplify
1 parent 182d35b commit 748e64d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Rules/Regexp/RegularExpressionPatternRule.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ private function validatePattern(string $pattern): ?string
128128
Strings::match('', $pattern);
129129
} catch (RegexpException $e) {
130130
if (str_contains($e->getMessage(), 'UTF-8 error')) {
131-
$lastColonPos = strrpos($e->getMessage(), ':');
132-
if ($lastColonPos === false) {
131+
$patternPos = strpos($e->getMessage(), 'pattern:');
132+
if ($patternPos === false) {
133133
throw new ShouldNotHappenException();
134134
}
135135
// strip invalid utf-8 pattern contents to keep the error message NEON parsable.
136-
return substr($e->getMessage(), 0, $lastColonPos);
136+
return substr($e->getMessage(), 0, $patternPos);
137137
}
138138
return $e->getMessage();
139139
}

0 commit comments

Comments
 (0)