mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-04-09 14:33:44 +00:00
Add LockTokenParser::parseIfCondition method and corresponding tests
- Implemented the `parseIfCondition` method in `LockTokenParser` to extract lock tokens from `if` headers. - Added `LockTokenParserTest` with multiple test cases using data providers to validate parsing logic, including scenarios with no headers, resource URIs, and "not" conditions.
This commit is contained in:
@@ -40,4 +40,19 @@ final readonly class LockTokenParser
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
public function parseIfCondition(Request $request): ?string
|
||||
{
|
||||
$if = $request->headers->get('if');
|
||||
|
||||
if (null === $if) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (preg_match('/\((?:not\s+)?<([^>]+)>/i', $if, $matches)) {
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user