From cdd43d728853a136e0beb4d5895f661bfc10123f Mon Sep 17 00:00:00 2001 From: Gustavo Freze Date: Sun, 4 Feb 2024 16:57:47 -0300 Subject: [PATCH] Release/3.0.1 - (#24) --- README.md | 2 +- src/HttpCode.php | 5 +++++ tests/HttpCodeTest.php | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 130a72d..8dc4847 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ $data = new Xyz(value: 10); $response = HttpResponse::ok(data: $data); $response->getStatusCode(); # 200 -$response->getReasonPhrase(); # 200 Ok +$response->getReasonPhrase(); # 200 OK $response->getBody()->getContents(); # {"value":10} ``` diff --git a/src/HttpCode.php b/src/HttpCode.php index 055fd22..3a51b1a 100644 --- a/src/HttpCode.php +++ b/src/HttpCode.php @@ -96,6 +96,11 @@ enum HttpCode: int public function message(): string { $subject = mb_convert_case($this->name, MB_CASE_TITLE); + + if ($this->value === self::OK->value) { + $subject = $this->name; + } + $message = str_replace('_', ' ', $subject); $template = '%s %s'; diff --git a/tests/HttpCodeTest.php b/tests/HttpCodeTest.php index ba57162..d56d907 100644 --- a/tests/HttpCodeTest.php +++ b/tests/HttpCodeTest.php @@ -35,7 +35,7 @@ public function providerForTestMessage(): array ], [ 'httpCode' => HttpCode::OK, - 'expected' => '200 Ok' + 'expected' => '200 OK' ], [ 'httpCode' => HttpCode::CREATED,