1: <?php
2: /**
3: * Created by PhpStorm.
4: * User: manus
5: * Date: 21/04/16
6: * Time: 8:44
7: */
8:
9: namespace GLFramework;
10:
11:
12: class Request
13: {
14:
15: var $params;
16: var $method;
17: var $uri;
18:
19: /**
20: * Request constructor.
21: * @param $params
22: * @param $method
23: * @param $uri
24: */
25: public function __construct($method, $uri)
26: {
27: // $this->params = $params;
28: $this->method = $method;
29: $this->uri = $uri;
30: }
31:
32: /**
33: * Obtiene los parametros de peticion
34: * @return mixed
35: */
36: public function getParams()
37: {
38: return $this->params;
39: }
40:
41: /**
42: * Establecer los parametros de peticion
43: * @param mixed $params
44: */
45: public function setParams($params)
46: {
47: $this->params = $params;
48: }
49:
50: /**
51: * Obtiene el metodo de peticion
52: * @return mixed
53: */
54: public function getMethod()
55: {
56: return $this->method;
57: }
58:
59: /**
60: * Establece el metodo de la meticion (GET, POST, PUT ...)
61: * @param mixed $method
62: */
63: public function setMethod($method)
64: {
65: $this->method = $method;
66: }
67:
68: /**
69: * Obtiene la url de la peticion
70: * @return mixed
71: */
72: public function getUri()
73: {
74: return $this->uri;
75: }
76:
77: /**
78: * Establecer la url de la peticion
79: * @param mixed $uri
80: */
81: public function setUri($uri)
82: {
83: $this->uri = $uri;
84: }
85:
86: /**
87: * Obtiene las cabeceras de la petición
88: * @return string
89: */
90: public function getHeaders()
91: {
92: $headers = '';
93: foreach ($_SERVER as $name => $value)
94: {
95: if (substr($name, 0, 5) == 'HTTP_')
96: {
97: $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
98: }
99: }
100: return $headers;
101: }
102:
103: /**
104: * Obtiene el header indicado
105: * @param $name
106: * @return mixed
107: */
108: public function getHeader($name)
109: {
110: $headers = $this->getHeaders();
111: return $headers[$name];
112: }
113:
114:
115: }