for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Doyo\UserBundle\Model;
/**
* Base group
* @author Anthonius Munthi <[email protected]>
*/
abstract class Group implements GroupInterface
{
* @var mixed
protected $id;
* @var string
protected $name;
* @var array
protected $roles;
* Group constructor.
*
* @param string $name
* @param array $roles
public function __construct($name, $roles = array())
$this->name = $name;
$this->roles = $roles;
}
* {@inheritdoc}
public function addRole($role)
if (!$this->hasRole($role)) {
$this->roles[] = strtoupper($role);
return $this;
public function getId()
return $this->id;
public function getName()
return $this->name;
public function hasRole($role)
return in_array(strtoupper($role), $this->roles, true);
public function getRoles()
return $this->roles;
public function removeRole($role)
if (false !== $key = array_search(strtoupper($role), $this->roles, true)) {
unset($this->roles[$key]);
$this->roles = array_values($this->roles);
public function setName($name)
public function setRoles(array $roles)