Skip to content

Commit a16574e

Browse files
committed
Make casing of http method enum keys consistent with the rest of the project
1 parent 0b49e32 commit a16574e

File tree

3 files changed

+52
-46
lines changed

3 files changed

+52
-46
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ HTTP Status codes are quite straight forward. For some code examples [you can lo
9393

9494
[![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)
9595

96-
| Key | Value |
97-
|------------------|------------------|
98-
| POST | POST |
99-
| PUT | PUT |
100-
| BASELINE_CONTROL | BASELINE-CONTROL |
101-
| ... | ... |
96+
| Key | Value |
97+
|-----------------|------------------|
98+
| Post | POST |
99+
| Put | PUT |
100+
| BaselineControl | BASELINE-CONTROL |
101+
| ... | ... |

dev/DataSource/Http/HttpMethodSource.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ public static function transformName(string $key): ?string
1616
return null; // According to https://www.rfc-editor.org/rfc/rfc9110.html#name-method-registration, section 18.2, this is a reserved method
1717
}
1818

19-
return $key;
19+
return preg_replace_callback(
20+
'/_([a-z])/',
21+
static function ($matches) {
22+
return mb_convert_case($matches[1], MB_CASE_UPPER);
23+
},
24+
ucfirst(strtolower($key))
25+
);
2026
}
2127

2228
public static function transformValue(string $value): string|int|null

src/Http/HttpMethod.php

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,43 @@
88
*/
99
enum HttpMethod: string
1010
{
11-
case ACL = 'ACL';
12-
case BASELINE_CONTROL = 'BASELINE-CONTROL';
13-
case BIND = 'BIND';
14-
case CHECKIN = 'CHECKIN';
15-
case CHECKOUT = 'CHECKOUT';
16-
case CONNECT = 'CONNECT';
17-
case COPY = 'COPY';
18-
case DELETE = 'DELETE';
19-
case GET = 'GET';
20-
case HEAD = 'HEAD';
21-
case LABEL = 'LABEL';
22-
case LINK = 'LINK';
23-
case LOCK = 'LOCK';
24-
case MERGE = 'MERGE';
25-
case MKACTIVITY = 'MKACTIVITY';
26-
case MKCALENDAR = 'MKCALENDAR';
27-
case MKCOL = 'MKCOL';
28-
case MKREDIRECTREF = 'MKREDIRECTREF';
29-
case MKWORKSPACE = 'MKWORKSPACE';
30-
case MOVE = 'MOVE';
31-
case OPTIONS = 'OPTIONS';
32-
case ORDERPATCH = 'ORDERPATCH';
33-
case PATCH = 'PATCH';
34-
case POST = 'POST';
35-
case PRI = 'PRI';
36-
case PROPFIND = 'PROPFIND';
37-
case PROPPATCH = 'PROPPATCH';
38-
case PUT = 'PUT';
39-
case REBIND = 'REBIND';
40-
case REPORT = 'REPORT';
41-
case SEARCH = 'SEARCH';
42-
case TRACE = 'TRACE';
43-
case UNBIND = 'UNBIND';
44-
case UNCHECKOUT = 'UNCHECKOUT';
45-
case UNLINK = 'UNLINK';
46-
case UNLOCK = 'UNLOCK';
47-
case UPDATE = 'UPDATE';
48-
case UPDATEREDIRECTREF = 'UPDATEREDIRECTREF';
49-
case VERSION_CONTROL = 'VERSION-CONTROL';
11+
case Acl = 'ACL';
12+
case BaselineControl = 'BASELINE-CONTROL';
13+
case Bind = 'BIND';
14+
case Checkin = 'CHECKIN';
15+
case Checkout = 'CHECKOUT';
16+
case Connect = 'CONNECT';
17+
case Copy = 'COPY';
18+
case Delete = 'DELETE';
19+
case Get = 'GET';
20+
case Head = 'HEAD';
21+
case Label = 'LABEL';
22+
case Link = 'LINK';
23+
case Lock = 'LOCK';
24+
case Merge = 'MERGE';
25+
case Mkactivity = 'MKACTIVITY';
26+
case Mkcalendar = 'MKCALENDAR';
27+
case Mkcol = 'MKCOL';
28+
case Mkredirectref = 'MKREDIRECTREF';
29+
case Mkworkspace = 'MKWORKSPACE';
30+
case Move = 'MOVE';
31+
case Options = 'OPTIONS';
32+
case Orderpatch = 'ORDERPATCH';
33+
case Patch = 'PATCH';
34+
case Post = 'POST';
35+
case Pri = 'PRI';
36+
case Propfind = 'PROPFIND';
37+
case Proppatch = 'PROPPATCH';
38+
case Put = 'PUT';
39+
case Rebind = 'REBIND';
40+
case Report = 'REPORT';
41+
case Search = 'SEARCH';
42+
case Trace = 'TRACE';
43+
case Unbind = 'UNBIND';
44+
case Uncheckout = 'UNCHECKOUT';
45+
case Unlink = 'UNLINK';
46+
case Unlock = 'UNLOCK';
47+
case Update = 'UPDATE';
48+
case Updateredirectref = 'UPDATEREDIRECTREF';
49+
case VersionControl = 'VERSION-CONTROL';
5050
}

0 commit comments

Comments
 (0)