Skip to content
This repository was archived by the owner on May 13, 2023. It is now read-only.

Commit 4e3ad46

Browse files
committed
Extract Response factory from Message factory
1 parent dc8d033 commit 4e3ad46

File tree

3 files changed

+45
-20
lines changed

3 files changed

+45
-20
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## UNRELEASED
4+
5+
### Added
6+
7+
- Response Factory in order to be reused in Message and Server Message factories
8+
9+
310
## 1.0.0-rc1 - 2015-12-14
411

512
### Added

src/MessageFactory.php

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
1414
*/
15-
interface MessageFactory
15+
interface MessageFactory extends ResponseInterface
1616
{
1717
/**
1818
* Creates a new PSR-7 request.
@@ -32,23 +32,4 @@ public function createRequest(
3232
$body = null,
3333
$protocolVersion = '1.1'
3434
);
35-
36-
/**
37-
* Creates a new PSR-7 response.
38-
*
39-
* @param int $statusCode
40-
* @param string|null $reasonPhrase
41-
* @param array $headers
42-
* @param resource|string|StreamInterface|null $body
43-
* @param string $protocolVersion
44-
*
45-
* @return ResponseInterface
46-
*/
47-
public function createResponse(
48-
$statusCode = 200,
49-
$reasonPhrase = null,
50-
array $headers = [],
51-
$body = null,
52-
$protocolVersion = '1.1'
53-
);
5435
}

src/ResponseFactory.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Http\Message;
4+
5+
use Psr\Http\Message\UriInterface;
6+
use Psr\Http\Message\RequestInterface;
7+
use Psr\Http\Message\ResponseInterface;
8+
use Psr\Http\Message\StreamInterface;
9+
10+
/**
11+
* Factory for PSR-7 Response.
12+
*
13+
* This factory contract can be reused in Message and Server Message factories.
14+
*
15+
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
16+
*/
17+
interface ResponseFactory
18+
{
19+
/**
20+
* Creates a new PSR-7 response.
21+
*
22+
* @param int $statusCode
23+
* @param string|null $reasonPhrase
24+
* @param array $headers
25+
* @param resource|string|StreamInterface|null $body
26+
* @param string $protocolVersion
27+
*
28+
* @return ResponseInterface
29+
*/
30+
public function createResponse(
31+
$statusCode = 200,
32+
$reasonPhrase = null,
33+
array $headers = [],
34+
$body = null,
35+
$protocolVersion = '1.1'
36+
);
37+
}

0 commit comments

Comments
 (0)