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:
2026-04-03 18:01:04 +02:00
parent ff9e4f2709
commit a1d72cefff
2 changed files with 85 additions and 0 deletions

View File

@@ -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;
}
}