Skip to content

Commit e25ac73

Browse files
committed
Add support for PSR-7 response
1 parent 1b9fdb5 commit e25ac73

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^8.2"
13+
"php": "^8.2",
14+
"psr/http-message": "^1.0 || ^2.0"
1415
},
1516
"require-dev": {
1617
"phpstan/phpstan": "1.10.33"

src/Response/Psr7Response.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace JakubBoucek\OpenWhisk\Runtime\Response;
6+
7+
use Psr\Http\Message\ResponseInterface;
8+
9+
class Psr7Response implements Response
10+
{
11+
private ResponseInterface $response;
12+
13+
public function __construct(ResponseInterface $response)
14+
{
15+
$this->response = $response;
16+
}
17+
18+
public function getArrayCopy(): array
19+
{
20+
return [
21+
self::BodyKey => (string)$this->response->getBody(),
22+
self::StatusCodeKey => $this->response->getStatusCode(),
23+
self::HeadersKey => $this->response->getHeaders()
24+
];
25+
}
26+
}

0 commit comments

Comments
 (0)