3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 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
;
12 use Zend\Uri\UriFactory
;
15 * @throws Exception\InvalidArgumentException
16 * @see http://tools.ietf.org/id/draft-abarth-origin-03.html#rfc.section.2
18 class Origin
implements HeaderInterface
23 protected $value = '';
25 public static function fromString($headerLine)
27 list($name, $value) = explode(': ', $headerLine, 2);
29 // check to ensure proper header type for this factory
30 if (strtolower($name) !== 'origin') {
31 throw new Exception\
InvalidArgumentException('Invalid header line for Origin string: "' . $name . '"');
34 $uri = UriFactory
::factory($value);
35 if (!$uri->isValid()) {
36 throw new Exception\
InvalidArgumentException('Invalid header value for Origin key: "' . $name . '"');
39 return new static($value);
43 * @param string|null $value
45 public function __construct($value = null)
48 HeaderValue
::assertValid($value);
49 $this->value
= $value;
53 public function getFieldName()
58 public function getFieldValue()
63 public function toString()
65 return 'Origin: ' . $this->getFieldValue();