Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
50.00% covered (warning)
50.00%
2 / 4
CRAP
77.78% covered (warning)
77.78%
7 / 9
ContentLength
0.00% covered (danger)
0.00%
0 / 1
50.00% covered (warning)
50.00%
2 / 4
5.27
77.78% covered (warning)
77.78%
7 / 9
 fromString($headerLine)
0.00% covered (danger)
0.00%
0 / 1
2.02
83.33% covered (warning)
83.33%
5 / 6
 getFieldName()
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getFieldValue()
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 toString()
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
<?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */
namespace Zend\Http\Header;
/**
 * @throws Exception\InvalidArgumentException
 * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13
 */
class ContentLength implements HeaderInterface
{
    public static function fromString($headerLine)
    {
        $header = new static();
        list($name, $value) = GenericHeader::splitHeaderLine($headerLine);
        // check to ensure proper header type for this factory
        if (strtolower($name) !== 'content-length') {
            throw new Exception\InvalidArgumentException('Invalid header line for Content-Length string: "' . $name . '"');
        }
        // @todo implementation details
        $header->value = $value;
        return $header;
    }
    public function getFieldName()
    {
        return 'Content-Length';
    }
    public function getFieldValue()
    {
        return $this->value;
    }
    public function toString()
    {
        return 'Content-Length: ' . $this->getFieldValue();
    }
}