diff --git a/README.md b/README.md index eb94ca94..1c40f975 100644 --- a/README.md +++ b/README.md @@ -93,9 +93,9 @@ HTTP Status codes are quite straight forward. For some code examples [you can lo [![Daily HTTP method spec update](https://github.com/PrinsFrank/standards/actions/workflows/update-spec-http-methods.yml/badge.svg)](https://github.com/PrinsFrank/standards/actions/workflows/update-spec-http-methods.yml) -| Key | Value | -|------------------|------------------| -| POST | POST | -| PUT | PUT | -| BASELINE_CONTROL | BASELINE-CONTROL | -| ... | ... | +| Key | Value | +|-----------------|------------------| +| Post | POST | +| Put | PUT | +| BaselineControl | BASELINE-CONTROL | +| ... | ... | diff --git a/dev/DataSource/Http/HttpMethodSource.php b/dev/DataSource/Http/HttpMethodSource.php index 66522975..7d60699b 100644 --- a/dev/DataSource/Http/HttpMethodSource.php +++ b/dev/DataSource/Http/HttpMethodSource.php @@ -16,7 +16,13 @@ public static function transformName(string $key): ?string return null; // According to https://www.rfc-editor.org/rfc/rfc9110.html#name-method-registration, section 18.2, this is a reserved method } - return $key; + return preg_replace_callback( + '/_([a-z])/', + static function ($matches) { + return mb_convert_case($matches[1], MB_CASE_UPPER); + }, + ucfirst(strtolower($key)) + ); } public static function transformValue(string $value): string|int|null diff --git a/src/Http/HttpMethod.php b/src/Http/HttpMethod.php index 685ae5e8..09461235 100644 --- a/src/Http/HttpMethod.php +++ b/src/Http/HttpMethod.php @@ -8,43 +8,43 @@ */ enum HttpMethod: string { - case ACL = 'ACL'; - case BASELINE_CONTROL = 'BASELINE-CONTROL'; - case BIND = 'BIND'; - case CHECKIN = 'CHECKIN'; - case CHECKOUT = 'CHECKOUT'; - case CONNECT = 'CONNECT'; - case COPY = 'COPY'; - case DELETE = 'DELETE'; - case GET = 'GET'; - case HEAD = 'HEAD'; - case LABEL = 'LABEL'; - case LINK = 'LINK'; - case LOCK = 'LOCK'; - case MERGE = 'MERGE'; - case MKACTIVITY = 'MKACTIVITY'; - case MKCALENDAR = 'MKCALENDAR'; - case MKCOL = 'MKCOL'; - case MKREDIRECTREF = 'MKREDIRECTREF'; - case MKWORKSPACE = 'MKWORKSPACE'; - case MOVE = 'MOVE'; - case OPTIONS = 'OPTIONS'; - case ORDERPATCH = 'ORDERPATCH'; - case PATCH = 'PATCH'; - case POST = 'POST'; - case PRI = 'PRI'; - case PROPFIND = 'PROPFIND'; - case PROPPATCH = 'PROPPATCH'; - case PUT = 'PUT'; - case REBIND = 'REBIND'; - case REPORT = 'REPORT'; - case SEARCH = 'SEARCH'; - case TRACE = 'TRACE'; - case UNBIND = 'UNBIND'; - case UNCHECKOUT = 'UNCHECKOUT'; - case UNLINK = 'UNLINK'; - case UNLOCK = 'UNLOCK'; - case UPDATE = 'UPDATE'; - case UPDATEREDIRECTREF = 'UPDATEREDIRECTREF'; - case VERSION_CONTROL = 'VERSION-CONTROL'; + case Acl = 'ACL'; + case BaselineControl = 'BASELINE-CONTROL'; + case Bind = 'BIND'; + case Checkin = 'CHECKIN'; + case Checkout = 'CHECKOUT'; + case Connect = 'CONNECT'; + case Copy = 'COPY'; + case Delete = 'DELETE'; + case Get = 'GET'; + case Head = 'HEAD'; + case Label = 'LABEL'; + case Link = 'LINK'; + case Lock = 'LOCK'; + case Merge = 'MERGE'; + case Mkactivity = 'MKACTIVITY'; + case Mkcalendar = 'MKCALENDAR'; + case Mkcol = 'MKCOL'; + case Mkredirectref = 'MKREDIRECTREF'; + case Mkworkspace = 'MKWORKSPACE'; + case Move = 'MOVE'; + case Options = 'OPTIONS'; + case Orderpatch = 'ORDERPATCH'; + case Patch = 'PATCH'; + case Post = 'POST'; + case Pri = 'PRI'; + case Propfind = 'PROPFIND'; + case Proppatch = 'PROPPATCH'; + case Put = 'PUT'; + case Rebind = 'REBIND'; + case Report = 'REPORT'; + case Search = 'SEARCH'; + case Trace = 'TRACE'; + case Unbind = 'UNBIND'; + case Uncheckout = 'UNCHECKOUT'; + case Unlink = 'UNLINK'; + case Unlock = 'UNLOCK'; + case Update = 'UPDATE'; + case Updateredirectref = 'UPDATEREDIRECTREF'; + case VersionControl = 'VERSION-CONTROL'; }