Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit cf963a9

Browse files
committed
Extracts new function, marshalMethodFromSapi()
Since we're doing this for headers, the URI, and the protocol version, makes sense to make this a function as well.
1 parent f311faf commit cf963a9

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"files": [
4141
"src/functions/create_uploaded_file.php",
4242
"src/functions/marshal_headers_from_sapi.php",
43+
"src/functions/marshal_method_from_sapi.php",
4344
"src/functions/marshal_protocol_version_from_sapi.php",
4445
"src/functions/marshal_uri_from_sapi.php",
4546
"src/functions/normalize_server.php",

src/ServerRequestFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static function fromGlobals(
9292
$server,
9393
$files,
9494
marshalUriFromSapi($server, $headers),
95-
array_key_exists('REQUEST_METHOD', $server) ? $server['REQUEST_METHOD'] : 'GET',
95+
marshalMethodFromSapi($server),
9696
'php://input',
9797
$headers,
9898
$cookies ?: $_COOKIE,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
4+
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace Zend\Diactoros;
9+
10+
/**
11+
* Retrieve the request method from the SAPI parameters.
12+
*
13+
* @param array $server
14+
* @return string
15+
*/
16+
function marshalMethodFromSapi(array $server)
17+
{
18+
return isset($server['REQUEST_METHOD']) ? $server['REQUEST_METHOD'] : 'GET';
19+
}

0 commit comments

Comments
 (0)