for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Borobudur-Http package.
*
* (c) Hexacodelabs <http://hexacodelabs.com>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Borobudur\Http\Header\Content;
use Borobudur\Http\Header\Exception\InvalidHeaderValueException;
use Borobudur\Http\Header\GenericHeader;
use Borobudur\Http\Header\HeaderFactoryTrait;
use Borobudur\Http\Header\HeaderInterface;
/**
* @author Iqbal Maulana <[email protected]>
* @created 8/3/15
abstract class AbstractContentHeader implements HeaderInterface
{
use HeaderFactoryTrait;
* @var string
protected static $headerName;
private $values;
* @param $value
public function __construct($value)
if (null === static::$headerName) {
throw new InvalidHeaderValueException(sprintf(
'Header name not defined on class "%s".',
get_called_class()
));
}
GenericHeader::assertHeaderValue($value);
$this->values = $value;
* Get header field name.
* @return string
public function getFieldName()
return static::$headerName;
* Get header field value.
* @return mixed
public function getFieldValue()
return $this->values;
* Cast header to string.
public function __toString()
return sprintf('%s: %s', $this->getFieldName(), $this->getFieldValue());