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;
/**
* @author Iqbal Maulana <[email protected]>
* @created 7/28/15
class UserAgentHeader implements HeaderInterface
{
* @var string
private $value;
* Constructor.
* @param string|null $value
public function __construct($value = null)
if (null !== $value) {
GenericHeader::assertHeaderValue($value);
$this->value = $value;
}
* Factory create UserAgentHeader from string representation.
* @param string $headerLine
* @return $this
public static function fromString($headerLine)
list($fieldName, $fieldValue) = GenericHeader::splitHeaderLine($headerLine);
$fieldName = str_replace(array(' ', '_', '.'), '-', $fieldName);
GenericHeader::assertHeaderFieldName('User-Agent', $fieldName);
return new static($fieldValue);
* Get header field name.
* @return string
public function getFieldName()
return 'User-Agent';
* Get header field value.
* @return mixed
public function getFieldValue()
return $this->value;
* Cast header to string.
public function __toString()
return sprintf('%s: %s', $this->getFieldName(), $this->getFieldValue());