more dependency injection!

This commit is contained in:
Taylor Otwell
2011-08-31 00:07:45 -05:00
parent c200f3eb1e
commit c7ddbbb018
20 changed files with 118 additions and 223 deletions

View File

@@ -9,6 +9,13 @@ class Request {
*/
public $server;
/**
* The $_POST array for the request.
*
* @var array
*/
private $post;
/**
* The route handling the current request.
*
@@ -27,12 +34,14 @@ class Request {
* Create a new request instance.
*
* @param array $server
* @param array $post
* @param string $url
* @return void
*/
public function __construct($server, $url)
public function __construct($server, $post, $url)
{
$this->url = $url;
$this->post = $post;
$this->server = $server;
}
@@ -84,7 +93,7 @@ class Request {
*/
public function method()
{
return ($this->spoofed()) ? $_POST['REQUEST_METHOD'] : $this->server['REQUEST_METHOD'];
return ($this->spoofed()) ? $this->post['REQUEST_METHOD'] : $this->server['REQUEST_METHOD'];
}
/**
@@ -96,7 +105,7 @@ class Request {
*/
public function spoofed()
{
return is_array($_POST) and array_key_exists('REQUEST_METHOD', $_POST);
return is_array($this->post) and array_key_exists('REQUEST_METHOD', $this->post);
}
/**