Skip to content

Commit

Permalink
Upgrade version to 2.0.
Browse files Browse the repository at this point in the history
Upgrading sunrise/http-message (v1.4.0 => v3.0.0)
  • Loading branch information
64j committed Jan 23, 2023
1 parent 858f064 commit 789b4ef
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ phpbench.json
phpcs.xml
phpunit.xml
vendor/
.idea
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
## Installation (via composer)

```bash
composer require 'arus/http-response-kit:^1.3'
composer require 'autorusltd/http-response-kit:^2.1'
```
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"require-dev": {
"phpunit/phpunit": "7.5.20|9.5.0",
"arus/php-coding-standard": "^1.0",
"sunrise/http-message": "^1.3",
"sunrise/http-message": "^3.0.0",
"laminas/laminas-diactoros": "^2.4|^2.5",
"symfony/validator": "^4.0"
},
Expand Down
23 changes: 10 additions & 13 deletions src/ResponseFactoryAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
*/
use Arus\Http\Response\Resource\Error;
use Arus\Http\Response\Resource\Errors;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface;
use Sunrise\Http\Message\Response\HtmlResponse;
use Sunrise\Http\Message\ResponseFactory;
use Symfony\Component\Validator\ConstraintViolationInterface;
use InvalidArgumentException;
Expand All @@ -33,20 +35,16 @@ trait ResponseFactoryAwareTrait
*/
protected $jsonOptions = 0;

/**
* @var int
*/
protected $jsonDepth = 512;

/**
* @param int $status
*
* @return ResponseInterface
*/
public function createResponse(int $status = 200) : ResponseInterface
{
return (new $this->responseFactory)
->createResponse($status);
/** @var ResponseFactory $factory */
$factory = (new $this->responseFactory);
return $factory->createResponse($status);
}

/**
Expand All @@ -57,20 +55,19 @@ public function createResponse(int $status = 200) : ResponseInterface
*/
public function html($content, int $status = 200) : ResponseInterface
{
return (new $this->responseFactory)
->createHtmlResponse($status, $content);
return new HtmlResponse($status, $content);
}

/**
* @param mixed $payload
* @param int $status
* @param array $headers
*
* @return ResponseInterface
*/
public function json($payload, int $status = 200) : ResponseInterface
public function json($payload, int $status = 200, array $headers = []) : ResponseInterface
{
return (new $this->responseFactory)
->createJsonResponse($status, $payload, $this->jsonOptions, $this->jsonDepth);
return new JsonResponse($status, $payload, $headers, $this->jsonOptions);
}

/**
Expand All @@ -90,7 +87,7 @@ public function ok($data = [], array $meta = [], int $status = 200) : ResponseIn

/**
* @param string $message
* @param string $source
* @param string|null $source
* @param mixed $code
* @param int $status
*
Expand Down

0 comments on commit 789b4ef

Please sign in to comment.