3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Http\Header
;
13 * @throws Exception\InvalidArgumentException
14 * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.47
16 class WWWAuthenticate
implements MultipleHeaderInterface
19 public static function fromString($headerLine)
21 $header = new static();
23 list($name, $value) = GenericHeader
::splitHeaderLine($headerLine);
25 // check to ensure proper header type for this factory
26 if (strtolower($name) !== 'www-authenticate') {
27 throw new Exception\
InvalidArgumentException('Invalid header line for WWW-Authenticate string: "' . $name . '"');
30 // @todo implementation details
31 $header->value
= $value;
36 public function getFieldName()
38 return 'WWW-Authenticate';
41 public function getFieldValue()
46 public function toString()
48 return 'WWW-Authenticate: ' . $this->getFieldValue();
51 public function toStringMultipleHeaders(array $headers)
53 $strings = array($this->toString());
54 foreach ($headers as $header) {
55 if (!$header instanceof WWWAuthenticate
) {
56 throw new Exception\
RuntimeException(
57 'The WWWAuthenticate multiple header implementation can only accept an array of WWWAuthenticate headers'
60 $strings[] = $header->toString();
62 return implode("\r\n", $strings);