Skip to content
This repository was archived by the owner on Jul 6, 2024. It is now read-only.

Commit 7e4bf8f

Browse files
author
Dominik Zogg
committed
v4
1 parent 25e2607 commit 7e4bf8f

File tree

4 files changed

+9
-76
lines changed

4 files changed

+9
-76
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ A simple http handler implementation for API.
1414
## Requirements
1515

1616
* php: ^7.2
17-
* chubbyphp/chubbyphp-deserialization: ^2.17.1
17+
* chubbyphp/chubbyphp-deserialization: ^3.0
1818
* chubbyphp/chubbyphp-negotiation: ^1.5.3
19-
* chubbyphp/chubbyphp-serialization: ^2.13.2
19+
* chubbyphp/chubbyphp-serialization: ^3.0
2020
* psr/http-factory: ^1.0.1
2121
* psr/http-message: ^1.0.1
2222
* psr/http-server-middleware: ^1.0.1
@@ -27,7 +27,7 @@ A simple http handler implementation for API.
2727
Through [Composer](http://getcomposer.org) as [chubbyphp/chubbyphp-api-http][1].
2828

2929
```sh
30-
composer require chubbyphp/chubbyphp-api-http "^3.4"
30+
composer require chubbyphp/chubbyphp-api-http "^4.0"
3131
```
3232

3333
## Usage

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
],
1212
"require": {
1313
"php": "^7.2",
14-
"chubbyphp/chubbyphp-deserialization": "^2.17.1",
14+
"chubbyphp/chubbyphp-deserialization": "^3.0@dev",
1515
"chubbyphp/chubbyphp-negotiation": "^1.5.3",
16-
"chubbyphp/chubbyphp-serialization": "^2.13.2",
16+
"chubbyphp/chubbyphp-serialization": "^3.0@dev",
1717
"psr/http-factory": "^1.0.1",
1818
"psr/http-message": "^1.0.1",
1919
"psr/http-server-middleware": "^1.0.1",
@@ -43,7 +43,7 @@
4343
},
4444
"extra": {
4545
"branch-alias": {
46-
"dev-master": "3.4-dev"
46+
"dev-master": "4.0-dev"
4747
}
4848
},
4949
"scripts": {

src/Manager/ResponseManager.php

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Chubbyphp\ApiHttp\Manager;
66

77
use Chubbyphp\ApiHttp\ApiProblem\ApiProblemInterface;
8-
use Chubbyphp\Deserialization\DeserializerInterface;
98
use Chubbyphp\Serialization\Normalizer\NormalizerContextInterface;
109
use Chubbyphp\Serialization\SerializerInterface;
1110
use Psr\Http\Message\ResponseFactoryInterface;
@@ -23,21 +22,10 @@ final class ResponseManager implements ResponseManagerInterface
2322
*/
2423
private $serializer;
2524

26-
public function __construct()
25+
public function __construct(ResponseFactoryInterface $responseFactory, SerializerInterface $serializer)
2726
{
28-
$args = func_get_args();
29-
30-
if ($args[0] instanceof DeserializerInterface) {
31-
@trigger_error(
32-
'Remove deserializer as first argument.',
33-
E_USER_DEPRECATED
34-
);
35-
36-
array_shift($args);
37-
}
38-
39-
$this->setResponseFactory($args[0]);
40-
$this->setSerializer($args[1]);
27+
$this->responseFactory = $responseFactory;
28+
$this->serializer = $serializer;
4129
}
4230

4331
/**
@@ -88,14 +76,4 @@ public function createFromApiProblem(
8876

8977
return $response;
9078
}
91-
92-
private function setResponseFactory(ResponseFactoryInterface $responseFactory): void
93-
{
94-
$this->responseFactory = $responseFactory;
95-
}
96-
97-
private function setSerializer(SerializerInterface $serializer): void
98-
{
99-
$this->serializer = $serializer;
100-
}
10179
}

tests/Unit/Manager/ResponseManagerTest.php

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Chubbyphp\ApiHttp\ApiProblem\ApiProblemInterface;
88
use Chubbyphp\ApiHttp\Manager\ResponseManager;
9-
use Chubbyphp\Deserialization\DeserializerInterface;
109
use Chubbyphp\Mock\Call;
1110
use Chubbyphp\Mock\MockByCallsTrait;
1211
use Chubbyphp\Serialization\Normalizer\NormalizerContextInterface;
@@ -26,50 +25,6 @@ final class ResponseManagerTest extends TestCase
2625
{
2726
use MockByCallsTrait;
2827

29-
public function testCreateWithDefaultsAndDeserializer(): void
30-
{
31-
$bodyString = '{"key": "value"}';
32-
33-
$object = new \stdClass();
34-
35-
/** @var DeserializerInterface|MockObject $deserializer */
36-
$deserializer = $this->getMockByCalls(DeserializerInterface::class);
37-
38-
/** @var StreamInterface|MockObject $body */
39-
$body = $this->getMockByCalls(StreamInterface::class, [
40-
Call::create('write')->with($bodyString),
41-
]);
42-
43-
/** @var Response|MockObject $response */
44-
$response = $this->getMockByCalls(Response::class, [
45-
Call::create('withHeader')->with('Content-Type', 'application/json')->willReturnSelf(),
46-
Call::create('getBody')->with()->willReturn($body),
47-
]);
48-
49-
/** @var ResponseFactoryInterface|MockObject $responseFactory */
50-
$responseFactory = $this->getMockByCalls(ResponseFactoryInterface::class, [
51-
Call::create('createResponse')->with(200, '')->willReturn($response),
52-
]);
53-
54-
/** @var SerializerInterface|MockObject $serializer */
55-
$serializer = $this->getMockByCalls(SerializerInterface::class, [
56-
Call::create('serialize')->with($object, 'application/json', null, '')->willReturn($bodyString),
57-
]);
58-
59-
error_clear_last();
60-
61-
$responseManager = new ResponseManager($deserializer, $responseFactory, $serializer);
62-
63-
$error = error_get_last();
64-
65-
self::assertNotNull($error);
66-
67-
self::assertSame(E_USER_DEPRECATED, $error['type']);
68-
self::assertSame('Remove deserializer as first argument.', $error['message']);
69-
70-
self::assertSame($response, $responseManager->create($object, 'application/json'));
71-
}
72-
7328
public function testCreateWithDefaults(): void
7429
{
7530
$bodyString = '{"key": "value"}';

0 commit comments

Comments
 (0)