1<?php 2 3/** 4 * @see https://github.com/laminas/laminas-http for the canonical source repository 5 * @copyright https://github.com/laminas/laminas-http/blob/master/COPYRIGHT.md 6 * @license https://github.com/laminas/laminas-http/blob/master/LICENSE.md New BSD License 7 */ 8 9namespace Laminas\Http\Header; 10 11/** 12 * @throws Exception\InvalidArgumentException 13 * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.40 14 */ 15class Trailer implements HeaderInterface 16{ 17 /** 18 * @var string 19 */ 20 protected $value; 21 22 public static function fromString($headerLine) 23 { 24 list($name, $value) = GenericHeader::splitHeaderLine($headerLine); 25 26 // check to ensure proper header type for this factory 27 if (strtolower($name) !== 'trailer') { 28 throw new Exception\InvalidArgumentException('Invalid header line for Trailer string: "' . $name . '"'); 29 } 30 31 // @todo implementation details 32 return new static($value); 33 } 34 35 public function __construct($value = null) 36 { 37 if ($value !== null) { 38 HeaderValue::assertValid($value); 39 $this->value = $value; 40 } 41 } 42 43 public function getFieldName() 44 { 45 return 'Trailer'; 46 } 47 48 public function getFieldValue() 49 { 50 return (string) $this->value; 51 } 52 53 public function toString() 54 { 55 return 'Trailer: ' . $this->getFieldValue(); 56 } 57} 58