Skip to content

Commit bfdc86b

Browse files
committed
rename addHeader() to setHeader()
1 parent 22a21b8 commit bfdc86b

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
7.1
55
---
66

7+
* Add `HttpOptions::setHeader()` to add or replace a single header
78
* Allow mocking `start_time` info in `MockResponse`
89
* Add `MockResponse::fromFile()` and `JsonMockResponse::fromFile()` methods to help using fixtures files
910

HttpOptions.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ public function setQuery(array $query): static
6666
/**
6767
* @return $this
6868
*/
69-
public function addHeader(string $key, string $value): static
69+
public function setHeader(string $key, string $value): static
7070
{
71-
$this->options['headers'] ??= [];
7271
$this->options['headers'][$key] = $value;
7372

7473
return $this;

Tests/HttpOptionsTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ public function testSetAuthBearer()
4040
$this->assertSame('foobar', (new HttpOptions())->setAuthBearer('foobar')->toArray()['auth_bearer']);
4141
}
4242

43-
public function testAddHeader()
43+
public function testSetHeader()
4444
{
4545
$options = new HttpOptions();
46-
$options->addHeader('Accept', 'application/json');
46+
$options->setHeader('Accept', 'application/json');
4747
$this->assertSame(['Accept' => 'application/json'], $options->toArray()['headers']);
48-
$options->addHeader('Accept-Language', 'en-US,en;q=0.5');
48+
$options->setHeader('Accept-Language', 'en-US,en;q=0.5');
4949
$this->assertSame(['Accept' => 'application/json', 'Accept-Language' => 'en-US,en;q=0.5'], $options->toArray()['headers']);
50-
$options->addHeader('Accept', 'application/html');
50+
$options->setHeader('Accept', 'application/html');
5151
$this->assertSame(['Accept' => 'application/html', 'Accept-Language' => 'en-US,en;q=0.5'], $options->toArray()['headers']);
5252
}
5353
}

0 commit comments

Comments
 (0)