Skip to content

Commit 4245298

Browse files
author
Jerome Thayananthajothy
committed
Bump version to 2.0.4 and add header manipulation methods in ClientHandler
1 parent 003d450 commit 4245298

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jerome/fetch-php",
33
"description": "The JavaScript fetch API for PHP.",
4-
"version": "2.0.3",
4+
"version": "2.0.4",
55
"type": "library",
66
"license": "MIT",
77
"authors": [
@@ -27,11 +27,12 @@
2727
"php": "^8.0",
2828
"guzzlehttp/guzzle": "^7.9",
2929
"guzzlehttp/psr7": "^2.7",
30-
"psr/http-message": "^1.0|^2.0",
31-
"jerome/matrix": "^2.0"
30+
"jerome/matrix": "^2.0",
31+
"psr/http-message": "^1.0|^2.0"
3232
},
3333
"require-dev": {
3434
"friendsofphp/php-cs-fixer": "^3.64",
35+
"laravel/pint": "^1.21",
3536
"mockery/mockery": "^1.6",
3637
"pestphp/pest": "^2.0|^3.0",
3738
"phpstan/phpstan": "^1.11.5",

src/Fetch/Http/ClientHandler.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,16 @@ public function withHeaders(array $headers): self
286286
return $this;
287287
}
288288

289+
/**
290+
* Set a single header for the request.
291+
*/
292+
public function withHeader(string $header, mixed $value): self
293+
{
294+
$this->options['headers'][$header] = $value;
295+
296+
return $this;
297+
}
298+
289299
/**
290300
* Set the body for the request.
291301
*/

src/Fetch/Interfaces/ClientHandler.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,26 @@ interface ClientHandler
1414
*/
1515
public static function handle(string $method, string $uri, array $options = []): mixed;
1616

17+
/**
18+
* Set the token for the request.
19+
*/
20+
public function withToken(string $token): self;
21+
22+
/**
23+
* Set the basic auth for the request.
24+
*/
25+
public function withAuth(string $username, string $password): self;
26+
1727
/**
1828
* Set the headers for the request.
1929
*/
2030
public function withHeaders(array $headers): self;
2131

32+
/**
33+
* Set a single header for the request.
34+
*/
35+
public function withHeader(string $header, mixed $value): self;
36+
2237
/**
2338
* Set the body for the request.
2439
*/

0 commit comments

Comments
 (0)