1 | <?php |
||
47 | class Response |
||
48 | { |
||
49 | /** |
||
50 | * @access protected |
||
51 | * @var RequestAbstract |
||
52 | */ |
||
53 | protected $_request; |
||
54 | |||
55 | /** |
||
56 | * @access protected |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $_data = array(); |
||
60 | |||
61 | /** |
||
62 | * @access protected |
||
63 | * @var array |
||
64 | */ |
||
65 | protected $_outputParts = array(); |
||
66 | |||
67 | /** |
||
68 | * @access protected |
||
69 | * @var string |
||
70 | */ |
||
71 | protected $_output; |
||
72 | |||
73 | /** |
||
74 | * Constructs the object |
||
75 | * |
||
76 | * @access public |
||
77 | * @param \Zepi\Turbo\Request\RequestAbstract $request |
||
78 | */ |
||
79 | public function __construct(RequestAbstract $request) |
||
83 | |||
84 | /** |
||
85 | * Return the data for the given key. If the key does |
||
86 | * not exists the function will return false. |
||
87 | * |
||
88 | * @access public |
||
89 | * @param string $key |
||
90 | * @return mixed |
||
91 | */ |
||
92 | public function getData($key) |
||
100 | |||
101 | /** |
||
102 | * Returns true if the given key is set. |
||
103 | * |
||
104 | * @access public |
||
105 | * @param string $key |
||
106 | * @return boolean |
||
107 | */ |
||
108 | public function hasData($key) |
||
112 | |||
113 | /** |
||
114 | * Saves the value for the given key in the response object. |
||
115 | * |
||
116 | * @access public |
||
117 | * @param string $key |
||
118 | * @param mixed $value |
||
119 | */ |
||
120 | public function setData($key, $value) |
||
124 | |||
125 | /** |
||
126 | * Returns the output for the given key. If the key does |
||
127 | * not exists the function will return false. |
||
128 | * |
||
129 | * @access public |
||
130 | * @param string $key |
||
131 | * @return false|string |
||
132 | */ |
||
133 | public function getOutputPart($key) |
||
141 | |||
142 | /** |
||
143 | * Returns true if the given key exists as output key. |
||
144 | * |
||
145 | * @access public |
||
146 | * @param string $key |
||
147 | * @return boolean |
||
148 | */ |
||
149 | public function hasOutputPart($key) |
||
153 | |||
154 | /** |
||
155 | * Saves the output for the given key in the Response object. |
||
156 | * |
||
157 | * @access public |
||
158 | * @param string $key |
||
159 | * @param string $output |
||
160 | */ |
||
161 | public function setOutputPart($key, $output) |
||
165 | |||
166 | /** |
||
167 | * Returns all output parts of the Response object. |
||
168 | * |
||
169 | * @access public |
||
170 | * @return array |
||
171 | */ |
||
172 | public function getOutputParts() |
||
176 | |||
177 | /** |
||
178 | * Returns the output of the response. |
||
179 | * |
||
180 | * @access public |
||
181 | * @return string |
||
182 | */ |
||
183 | public function getOutput() |
||
187 | |||
188 | /** |
||
189 | * Returns true if the response has an output. |
||
190 | * |
||
191 | * @access public |
||
192 | * @return boolean |
||
193 | */ |
||
194 | public function hasOutput() |
||
198 | |||
199 | /** |
||
200 | * Sets the output of the response. |
||
201 | * |
||
202 | * @access public |
||
203 | * @param string $output |
||
204 | */ |
||
205 | public function setOutput($output) |
||
209 | |||
210 | /** |
||
211 | * Set the Location header to redirect a request |
||
212 | * |
||
213 | * @access public |
||
214 | * @param string $target |
||
215 | * @param integer $headerCode |
||
216 | * @param boolean $withOrigin |
||
217 | */ |
||
218 | public function redirectTo($target, $headerCode = 301, $withOrigin = false) |
||
242 | |||
243 | /** |
||
244 | * Returns a full url for the given url parts array |
||
245 | * from the function `parse_url()`. |
||
246 | * |
||
247 | * @access public |
||
248 | * @param array $urlParts |
||
249 | * @return string |
||
250 | */ |
||
251 | public function buildUrl($urlParts) |
||
296 | } |
||
297 |
This check looks for type mismatches where the missing type is
false
. This is usually indicative of an error condtion.Consider the follow example
This function either returns a new
DateTime
object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returnedfalse
before passing on the value to another function or method that may not be able to handle afalse
.