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.40
15 */
16class Trailer 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) !== 'trailer') {
29            throw new Exception\InvalidArgumentException('Invalid header line for Trailer string: "' . $name . '"');
30        }
31
32        // @todo implementation details
33        $header = new static($value);
34
35        return $header;
36    }
37
38    public function __construct($value = null)
39    {
40        if ($value) {
41            HeaderValue::assertValid($value);
42            $this->value = $value;
43        }
44    }
45
46    public function getFieldName()
47    {
48        return 'Trailer';
49    }
50
51    public function getFieldValue()
52    {
53        return $this->value;
54    }
55
56    public function toString()
57    {
58        return 'Trailer: ' . $this->getFieldValue();
59    }
60}
61