Skip to content

Commit

Permalink
fix: Fixes HTTP code message.
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavofreze committed Feb 4, 2024
1 parent c7c71bd commit f47099f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
```

Expand Down
5 changes: 5 additions & 0 deletions src/HttpCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion tests/HttpCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function providerForTestMessage(): array
],
[
'httpCode' => HttpCode::OK,
'expected' => '200 Ok'
'expected' => '200 OK'
],
[
'httpCode' => HttpCode::CREATED,
Expand Down

0 comments on commit f47099f

Please sign in to comment.