Skip to content

Commit 8150927

Browse files
minor symfony#61196 [HttpFoundation] Simplify UriSigner::verify to use match (alexander-schranz)
This PR was merged into the 7.4 branch. Discussion ---------- [HttpFoundation] Simplify UriSigner::verify to use match | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? |no | New feature? | no <!-- if yes, also update src/**/CHANGELOG.md --> | Deprecations? | no <!-- if yes, also update UPGRADE-*.md and src/**/CHANGELOG.md --> | Issues | Fix #... <!-- prefix each issue number with "Fix #"; no need to create an issue if none exists, explain below --> | License | MIT Simplify UriSigner::verify to use match. /cc `@kbond` what do you think? Commits ------- 6bc2719 Simplify UriSigner::verify to use match
2 parents 235c8a5 + 6bc2719 commit 8150927

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)