Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create an interface * cs * Added getHeadersFromServer * cs * Added tests * cs * Added changelog * Allow to set body * cs
- Loading branch information
Showing
4 changed files
with
174 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nyholm\Psr7Server; | ||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Message\StreamInterface; | ||
|
||
interface ServerRequestCreatorInterface | ||
{ | ||
/** | ||
* Create a new server request from the current environment variables. | ||
* Defaults to a GET request to minimise the risk of an \InvalidArgumentException. | ||
* Includes the current request headers as supplied by the server through `getallheaders()`. | ||
* | ||
* @throws \InvalidArgumentException If no valid method or URI can be determined. | ||
*/ | ||
public function fromGlobals(): ServerRequestInterface; | ||
|
||
/** | ||
* Create a new server request from a set of arrays. | ||
* | ||
* @param array $server Typically $_SERVER or similar structure. | ||
* @param array $headers Typically the output of getallheaders() or similar structure. | ||
* @param array $cookie Typically $_COOKIE or similar structure. | ||
* @param array $get Typically $_GET or similar structure. | ||
* @param array $post Typically $_POST or similar structure. | ||
* @param array $files Typically $_FILES or similar structure. | ||
* @param StreamInterface|resource|string|null $body Typically stdIn | ||
* | ||
* @throws \InvalidArgumentException If no valid method or URI can be determined. | ||
*/ | ||
public function fromArrays( | ||
array $server, | ||
array $headers = [], | ||
array $cookie = [], | ||
array $get = [], | ||
array $post = [], | ||
array $files = [], | ||
$body = null | ||
): ServerRequestInterface; | ||
|
||
/** | ||
* Get parsed headers from ($_SERVER) array. | ||
* | ||
* @param array $server Typically $_SERVER or similar structure. | ||
* | ||
* @return array | ||
*/ | ||
public function getHeadersFromServer(array $server): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters