diff --git a/README.md b/README.md index 44a548b..ace50ce 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ![Chevere](chevere.svg) -[![Build](https://img.shields.io/github/actions/workflow/status/chevere/http/test.yml?branch=0.4&style=flat-square)](https://github.com/chevere/http/actions) +[![Build](https://img.shields.io/github/actions/workflow/status/chevere/http/test.yml?branch=0.5&style=flat-square)](https://github.com/chevere/http/actions) ![Code size](https://img.shields.io/github/languages/code-size/chevere/http?style=flat-square) [![Apache-2.0](https://img.shields.io/github/license/chevere/http?style=flat-square)](LICENSE) [![PHPStan](https://img.shields.io/badge/PHPStan-level%209-blueviolet?style=flat-square)](https://phpstan.org/) -[![Mutation testing badge](https://img.shields.io/endpoint?style=flat-square&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fchevere%2Fhttp%2F0.4)](https://dashboard.stryker-mutator.io/reports/github.com/chevere/http/0.4) +[![Mutation testing badge](https://img.shields.io/endpoint?style=flat-square&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fchevere%2Fhttp%2F0.5)](https://dashboard.stryker-mutator.io/reports/github.com/chevere/http/0.5) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=chevere_http&metric=alert_status)](https://sonarcloud.io/dashboard?id=chevere_http) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=chevere_http&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=chevere_http) diff --git a/src/Headers.php b/src/Headers.php index debc20b..a604da3 100644 --- a/src/Headers.php +++ b/src/Headers.php @@ -33,7 +33,7 @@ public function __construct(Header ...$header) /** * @return array */ - public function toArray(): array + public function toLines(): array { $return = []; foreach ($this->getIterator() as $header) { @@ -43,6 +43,19 @@ public function toArray(): array return $return; } + /** + * @return array + */ + public function toArray(): array + { + $return = []; + foreach ($this->getIterator() as $header) { + $return[$header->name] = $header->value; + } + + return $return; + } + /** * @return VectorInterface */ diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php index aeaf2bd..17cb190 100644 --- a/tests/FunctionsTest.php +++ b/tests/FunctionsTest.php @@ -46,7 +46,7 @@ public function testGetRequest(): void [ $header->line, ], - $request->headers->toArray() + $request->headers->toLines() ); } @@ -68,7 +68,7 @@ public function testGetResponse(): void $contentType->line, $contentType2->line, ], - $response->headers->toArray() + $response->headers->toLines() ); } } diff --git a/tests/HeadersTest.php b/tests/HeadersTest.php index 3d2e88c..f3434fa 100644 --- a/tests/HeadersTest.php +++ b/tests/HeadersTest.php @@ -34,6 +34,10 @@ public function testHeaders(): void $this->assertSame([ 'foo: bar', 'foo: baz', + ], $headers->toLines()); + $this->assertSame([ + 'foo' => 'bar', + 'foo' => 'baz', ], $headers->toArray()); } }