Skip to content

Commit

Permalink
update, bug fixed for factory
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Oct 20, 2017
1 parent af334b1 commit 6514ba7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/HttpFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class HttpFactory
*/
public static function createRequest($method, $uri)
{
if (is_string($uri)) {
$uri = Uri::createFromString($uri);
}

return new Request($method, $uri);
}

Expand Down Expand Up @@ -78,19 +82,23 @@ public static function createResponse($code = 200)
*/
public static function createServerRequest($method, $uri)
{
if (is_string($uri)) {
$uri = Uri::createFromString($uri);
}

return new Request($method, $uri);
}

/**
* Create a new server request from server variables.
* @param array $server Typically $_SERVER or similar structure.
* @param array|CollectionInterface $server Typically $_SERVER or similar structure.
* @return ServerRequestInterface
* @throws \InvalidArgumentException
* If no valid method or URI can be determined.
*/
public static function createServerRequestFromArray(array $server)
public static function createServerRequestFromArray($server)
{
$env = new SimpleCollection($server);
$env = self::ensureIsCollection($server);
$method = $env['REQUEST_METHOD'];
$uri = static::createUriFromArray($env);
$headers = static::createHeadersFromArray($env);
Expand Down Expand Up @@ -337,4 +345,4 @@ public static function ensureIsCollection($data)

return new SimpleCollection((array)$data);
}
}
}

0 comments on commit 6514ba7

Please sign in to comment.