Skip to content

Commit

Permalink
Make casing of http method enum keys consistent with the rest of the …
Browse files Browse the repository at this point in the history
…project
  • Loading branch information
PrinsFrank committed Nov 26, 2022
1 parent 0b49e32 commit a16574e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 46 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| ... | ... |
8 changes: 7 additions & 1 deletion dev/DataSource/Http/HttpMethodSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
78 changes: 39 additions & 39 deletions src/Http/HttpMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

0 comments on commit a16574e

Please sign in to comment.