Skip to content

Commit 6bc2719

Browse files
Simplify UriSigner::verify to use match
1 parent 235c8a5 commit 6bc2719

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/Symfony/Component/HttpFoundation/UriSigner.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,12 @@ public function verify(Request|string $uri): void
121121
$uri = self::normalize($uri);
122122
$status = $this->doVerify($uri);
123123

124-
if (self::STATUS_VALID === $status) {
125-
return;
126-
}
127-
128-
if (self::STATUS_MISSING === $status) {
129-
throw new UnsignedUriException();
130-
}
131-
132-
if (self::STATUS_INVALID === $status) {
133-
throw new UnverifiedSignedUriException();
134-
}
135-
136-
throw new ExpiredSignedUriException();
124+
match ($status) {
125+
self::STATUS_VALID => null,
126+
self::STATUS_INVALID => throw new UnverifiedSignedUriException(),
127+
self::STATUS_EXPIRED => throw new ExpiredSignedUriException(),
128+
default => throw new UnsignedUriException(),
129+
};
137130
}
138131

139132
private function computeHash(string $uri): string

0 commit comments

Comments
 (0)