for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Leogout\Bundle\SeoBundle\Model;
/**
* Description of MetaTag.
*
* @author: leogout
*/
class MetaTag implements RenderableInterface
{
const NAME_TYPE = 'name';
const PROPERTY_TYPE = 'property';
const HTTP_EQUIV_TYPE = 'http-equiv';
* @var string
protected $type = self::NAME_TYPE;
protected $value;
protected $content;
* @return string
public function getType()
return $this->type;
}
* @param string $type
* @return $this
public function setType($type)
if (!in_array($type, $this->getTypes())) {
throw new \InvalidArgumentException(sprintf('Meta tag of type "%s" doesn\'t exist. Existing types are: name, property and http-equiv.', $type));
$this->type = $type;
return $this;
public function getValue()
return $this->value;
* @param string $value
public function setValue($value)
$this->value = (string) $value;
public function getContent()
return $this->content;
* @param string $content
public function setContent($content)
$this->content = (string) $content;
* @return array
public function getTypes()
return [
self::NAME_TYPE,
self::PROPERTY_TYPE,
self::HTTP_EQUIV_TYPE,
];
public function render()
return sprintf('<meta %s="%s" content="%s" />', $this->getType(), $this->getValue(), $this->getContent());
public function __toString()
return $this->render();