getData uses the super-global variable $_REQUEST which is generally not recommended.
Instead of super-globals, we recommend to explicitly inject the dependencies
of your class. This makes your code less dependent on global state and it
becomes generally more testable:
// BadclassRouter{publicfunctiongenerate($path){return$_SERVER['HOST'].$path;}}// BetterclassRouter{private$host;publicfunction__construct($host){$this->host=$host;}publicfunctiongenerate($path){return$this->host.$path;}}classController{publicfunctionmyAction(Request$request){// Instead of$page=isset($_GET['page'])?intval($_GET['page']):1;// Better (assuming you use the Symfony2 request)$page=$request->query->get('page',1);}}
Loading history...
23
{
24
3
return $_REQUEST;
25
}
26
27
/**
28
* @return ResponseInterface
29
*/
30
3
public function send()
31
{
32
3
return $this->sendData($this->getData());
33
}
34
35
/**
36
* Send the request with specified data
37
*
38
* @param mixed $data The data to send
39
* @return ResponseInterface
40
*/
41
3
public function sendData($data)
42
{
43
3
return $this->response = new CompletePurchaseResponse($this, $data);
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: