comparison vendor/zendframework/zend-feed/src/PubSubHubbub/HttpResponse.php @ 2:5311817fb629

Theme updates
author Chris Cannam
date Tue, 10 Jul 2018 13:19:18 +0000
parents c75dbcec494b
children a9cd425dd02b
comparison
equal deleted inserted replaced
1:0b0e5f3b1e83 2:5311817fb629
58 } elseif (200 == $this->statusCode) { 58 } elseif (200 == $this->statusCode) {
59 return; 59 return;
60 } 60 }
61 $httpCodeSent = false; 61 $httpCodeSent = false;
62 foreach ($this->headers as $header) { 62 foreach ($this->headers as $header) {
63 if (!$httpCodeSent && $this->statusCode) { 63 if (! $httpCodeSent && $this->statusCode) {
64 header($header['name'] . ': ' . $header['value'], $header['replace'], $this->statusCode); 64 header($header['name'] . ': ' . $header['value'], $header['replace'], $this->statusCode);
65 $httpCodeSent = true; 65 $httpCodeSent = true;
66 } else { 66 } else {
67 header($header['name'] . ': ' . $header['value'], $header['replace']); 67 header($header['name'] . ': ' . $header['value'], $header['replace']);
68 } 68 }
69 } 69 }
70 if (!$httpCodeSent) { 70 if (! $httpCodeSent) {
71 header('HTTP/1.1 ' . $this->statusCode); 71 header('HTTP/1.1 ' . $this->statusCode);
72 } 72 }
73 } 73 }
74 74
75 /** 75 /**
138 */ 138 */
139 public function canSendHeaders($throw = false) 139 public function canSendHeaders($throw = false)
140 { 140 {
141 $ok = headers_sent($file, $line); 141 $ok = headers_sent($file, $line);
142 if ($ok && $throw) { 142 if ($ok && $throw) {
143 throw new Exception\RuntimeException('Cannot send headers; headers already sent in ' . $file . ', line ' . $line); 143 throw new Exception\RuntimeException(
144 } 144 'Cannot send headers; headers already sent in ' . $file . ', line ' . $line
145 return !$ok; 145 );
146 }
147 return ! $ok;
146 } 148 }
147 149
148 /** 150 /**
149 * Set HTTP response code to use with headers 151 * Set HTTP response code to use with headers
150 * 152 *
152 * @return HttpResponse 154 * @return HttpResponse
153 * @throws Exception\InvalidArgumentException 155 * @throws Exception\InvalidArgumentException
154 */ 156 */
155 public function setStatusCode($code) 157 public function setStatusCode($code)
156 { 158 {
157 if (!is_int($code) || (100 > $code) || (599 < $code)) { 159 if (! is_int($code) || (100 > $code) || (599 < $code)) {
158 throw new Exception\InvalidArgumentException('Invalid HTTP response' 160 throw new Exception\InvalidArgumentException('Invalid HTTP response'
159 . ' code:' . $code); 161 . ' code:' . $code);
160 } 162 }
161 $this->statusCode = $code; 163 $this->statusCode = $code;
162 return $this; 164 return $this;
199 * Normalizes a header name to X-Capitalized-Names 201 * Normalizes a header name to X-Capitalized-Names
200 * 202 *
201 * @param string $name 203 * @param string $name
202 * @return string 204 * @return string
203 */ 205 */
206 // @codingStandardsIgnoreStart
204 protected function _normalizeHeader($name) 207 protected function _normalizeHeader($name)
205 { 208 {
209 // @codingStandardsIgnoreEnd
206 $filtered = str_replace(['-', '_'], ' ', (string) $name); 210 $filtered = str_replace(['-', '_'], ' ', (string) $name);
207 $filtered = ucwords(strtolower($filtered)); 211 $filtered = ucwords(strtolower($filtered));
208 $filtered = str_replace(' ', '-', $filtered); 212 $filtered = str_replace(' ', '-', $filtered);
209 return $filtered; 213 return $filtered;
210 } 214 }