Skip to content

Commit

Permalink
add psr17 support
Browse files Browse the repository at this point in the history
  • Loading branch information
verfriemelt-dot-org committed Nov 21, 2024
1 parent 1f156fa commit e164cde
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 1 deletion.
18 changes: 18 additions & 0 deletions _/HttpClient/Psr7/ResponseFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace verfriemelt\wrapped\_\HttpClient\Psr7;

use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Override;

final class ResponseFactory implements ResponseFactoryInterface
{
#[Override]
public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface
{
return new Response($code, $reasonPhrase);
}
}
21 changes: 21 additions & 0 deletions _/HttpClient/Psr7/ServerRequestFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace verfriemelt\wrapped\_\HttpClient\Psr7;

use Psr\Http\Message\ServerRequestFactoryInterface;
use Psr\Http\Message\ServerRequestInterface;
use Override;

final class ServerRequestFactory implements ServerRequestFactoryInterface
{
/**
* @param array<string|int,mixed> $serverParams
*/
#[Override]
public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface
{
return new ServerRequest($method, $uri, server: $serverParams);
}
}
3 changes: 2 additions & 1 deletion _/HttpClient/Psr7/StreamFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

namespace verfriemelt\wrapped\_\HttpClient\Psr7;

use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\StreamInterface;
use Override;

final class StreamFactory implements \Psr\Http\Message\StreamFactoryInterface
final class StreamFactory implements StreamFactoryInterface
{
#[Override]
public function createStream(string $content = ''): StreamInterface
Expand Down
30 changes: 30 additions & 0 deletions _/HttpClient/Psr7/UploadedFileFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace verfriemelt\wrapped\_\HttpClient\Psr7;

use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UploadedFileFactoryInterface;
use Psr\Http\Message\UploadedFileInterface;
use Override;

final class UploadedFileFactory implements UploadedFileFactoryInterface
{
#[Override]
public function createUploadedFile(
StreamInterface $stream,
?int $size = null,
int $error = \UPLOAD_ERR_OK,
?string $clientFilename = null,
?string $clientMediaType = null,
): UploadedFileInterface {

return new UploadedFile(
$stream,
$error,
$clientFilename,
$clientMediaType,
);
}
}

0 comments on commit e164cde

Please sign in to comment.