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

Commit afe5891

Browse files
committed
Merge pull request #16 from php-http/extract_response_factory
Extract Response factory from Message factory
2 parents acec14f + d8b02e3 commit afe5891

File tree

4 files changed

+82
-43
lines changed

4 files changed

+82
-43
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
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+
- Request Factory
9+
10+
### Changed
11+
12+
- Message Factory extends Request and Response factories
13+
14+
315
## 1.0.0-rc1 - 2015-12-14
416

517
### Added

src/MessageFactory.php

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,11 @@
22

33
namespace Http\Message;
44

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-
105
/**
116
* Factory for PSR-7 Request and Response.
127
*
138
* @author Márk Sági-Kazár <[email protected]>
149
*/
15-
interface MessageFactory
10+
interface MessageFactory extends RequestFactory, ResponseFactory
1611
{
17-
/**
18-
* Creates a new PSR-7 request.
19-
*
20-
* @param string $method
21-
* @param string|UriInterface $uri
22-
* @param array $headers
23-
* @param resource|string|StreamInterface|null $body
24-
* @param string $protocolVersion
25-
*
26-
* @return RequestInterface
27-
*/
28-
public function createRequest(
29-
$method,
30-
$uri,
31-
array $headers = [],
32-
$body = null,
33-
$protocolVersion = '1.1'
34-
);
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-
);
5412
}

src/RequestFactory.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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\StreamInterface;
8+
9+
/**
10+
* Factory for PSR-7 Request.
11+
*
12+
* @author Márk Sági-Kazár <[email protected]>
13+
*/
14+
interface RequestFactory
15+
{
16+
/**
17+
* Creates a new PSR-7 request.
18+
*
19+
* @param string $method
20+
* @param string|UriInterface $uri
21+
* @param array $headers
22+
* @param resource|string|StreamInterface|null $body
23+
* @param string $protocolVersion
24+
*
25+
* @return RequestInterface
26+
*/
27+
public function createRequest(
28+
$method,
29+
$uri,
30+
array $headers = [],
31+
$body = null,
32+
$protocolVersion = '1.1'
33+
);
34+
}

src/ResponseFactory.php

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

0 commit comments

Comments
 (0)