for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace DoS\TaggingBundle\Model;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
class Tag implements TagInterface
{
/**
* @var int
*/
protected $id;
* @var string
protected $name;
* @var Collection|TaggingInterface[]
protected $taggings;
public function __construct()
$this->taggings = new ArrayCollection();
}
* {@inheritdoc}
public function getId()
return $this->id;
public function getName()
return $this->name;
public function setName($name)
$this->name = preg_replace('/\s++/', ' ', $name);
public function getTaggings()
return $this->taggings;
public function setTaggings($taggings)
if (!$taggings instanceof Collection) {
$taggings = new ArrayCollection($taggings);
foreach($taggings as $tagging) {
$tagging->setTag($this);
$this->taggings = $taggings;
public function hasTagging(TaggingInterface $tagging)
return $this->taggings->contains($tagging);
public function addTagging(TaggingInterface $tagging)
if (!$this->hasTagging($tagging)) {
$this->taggings->add($tagging);
public function removeTagging(TaggingInterface $tagging)
if ($this->hasTagging($tagging)) {
$tagging->setTag(null);
$this->taggings->removeElement($tagging);