- Added an HttpFactory and beginning the removal of old annotations from Notes
This commit is contained in:
1 parent
7e92391113
commit
08c27e38b0
10 files changed
+143
-52
No files matched your search
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Lean\Factory;
|
||||
|
||||
use Laminas\Diactoros\Response\{EmptyResponse, HtmlResponse, JsonResponse, RedirectResponse, TextResponse};
|
||||
use Lean\Response\{ DownloadResponse, ImageResponse, FileDownloadResponse, PdfResponse };
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class HttpFactory
|
||||
{
|
||||
public static function createRedirectResponse(string $url, int $code = 302, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new RedirectResponse($url, $code, $headers);
|
||||
}
|
||||
|
||||
public static function createHtmlResponse(string $html, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new HtmlResponse($html, $code, $headers);
|
||||
}
|
||||
|
||||
public static function createTextResponse(string $text, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new TextResponse($text, $code, $headers);
|
||||
}
|
||||
|
||||
public static function createJsonResponse(mixed $data, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new JsonResponse($data, $code, $headers);
|
||||
}
|
||||
|
||||
public static function createEmptyResponse(int $code = 204, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new EmptyResponse($code, $headers);
|
||||
}
|
||||
|
||||
public static function createPdfResponse(string $binary, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new PdfResponse($binary, $code, $headers);
|
||||
}
|
||||
|
||||
public static function createDownloadableResponse(string $data, string $filename, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new DownloadResponse($data, $filename, $code, $headers);
|
||||
}
|
||||
|
||||
public static function createImageResponse(string $data, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new ImageResponse($data, $code, $headers);
|
||||
}
|
||||
|
||||
public static function createFileDownloadResponse(string $path, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new FileDownloadResponse($path, $code, $headers);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user