for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Spiral Framework.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/
declare(strict_types=1);
namespace Spiral\Tests\Http\Diactoros;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Spiral\Http\Config\HttpConfig;
use Laminas\Diactoros\Response;
final class ResponseFactory implements ResponseFactoryInterface
{
/** @var HttpConfig */
protected $config;
* @param HttpConfig $config
public function __construct(HttpConfig $config)
$this->config = $config;
}
* @param int $code
* @param string $reasonPhrase
* @return ResponseInterface
public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface
$response = new Response('php://memory', $code, []);
$response = $response->withStatus($code, $reasonPhrase);
foreach ($this->config->getBaseHeaders() as $header => $value) {
$response = $response->withAddedHeader($header, $value);
return $response;