1<?php 2/** 3 * Zend Framework (http://framework.zend.com/) 4 * 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 8 */ 9 10namespace Zend\Http\Header; 11 12/** 13 * @throws Exception\InvalidArgumentException 14 * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.31 15 */ 16class MaxForwards implements HeaderInterface 17{ 18 /** 19 * @var string 20 */ 21 protected $value; 22 23 public static function fromString($headerLine) 24 { 25 list($name, $value) = GenericHeader::splitHeaderLine($headerLine); 26 27 // check to ensure proper header type for this factory 28 if (strtolower($name) !== 'max-forwards') { 29 throw new Exception\InvalidArgumentException(sprintf( 30 'Invalid header line for Max-Forwards string: "%s"', 31 $name 32 )); 33 } 34 35 // @todo implementation details 36 $header = new static($value); 37 38 return $header; 39 } 40 41 public function __construct($value = null) 42 { 43 if ($value) { 44 HeaderValue::assertValid($value); 45 $this->value = $value; 46 } 47 } 48 49 public function getFieldName() 50 { 51 return 'Max-Forwards'; 52 } 53 54 public function getFieldValue() 55 { 56 return $this->value; 57 } 58 59 public function toString() 60 { 61 return 'Max-Forwards: ' . $this->getFieldValue(); 62 } 63} 64