View file vendor/slim/psr7/src/Factory/ResponseFactory.php

File size: 779B
  1. <?php
  2.  
  3. /**
  4. * Slim Framework (https://slimframework.com)
  5. *
  6. * @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
  7. */
  8.  
  9. declare(strict_types=1);
  10.  
  11. namespace Slim\Psr7\Factory;
  12.  
  13. use Fig\Http\Message\StatusCodeInterface;
  14. use Psr\Http\Message\ResponseFactoryInterface;
  15. use Psr\Http\Message\ResponseInterface;
  16. use Slim\Psr7\Response;
  17.  
  18. class ResponseFactory implements ResponseFactoryInterface
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function createResponse(
  24. int $code = StatusCodeInterface::STATUS_OK,
  25. string $reasonPhrase = ''
  26. ): ResponseInterface {
  27. $res = new Response($code);
  28.  
  29. if ($reasonPhrase !== '') {
  30. $res = $res->withStatus($code, $reasonPhrase);
  31. }
  32.  
  33. return $res;
  34. }
  35. }