| Total Complexity | 11 | 
| Total Lines | 104 | 
| Duplicated Lines | 0 % | 
| Coverage | 88.46% | 
| Changes | 0 | ||
| 1 | <?php | ||
| 9 | abstract class Group implements GroupInterface | ||
| 10 | { | ||
| 11 | /** | ||
| 12 | * @var mixed | ||
| 13 | */ | ||
| 14 | protected $id; | ||
| 15 | |||
| 16 | /** | ||
| 17 | * @var string | ||
| 18 | */ | ||
| 19 | protected $name; | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @var array | ||
| 23 | */ | ||
| 24 | protected $roles; | ||
| 25 | |||
| 26 | /** | ||
| 27 | * Group constructor. | ||
| 28 | * | ||
| 29 | * @param string $name | ||
| 30 | * @param array $roles | ||
| 31 | */ | ||
| 32 | 11 | public function __construct($name, $roles = array()) | |
| 36 | } | ||
| 37 | |||
| 38 | /** | ||
| 39 |      * {@inheritdoc} | ||
| 40 | */ | ||
| 41 | 4 | public function addRole($role) | |
| 42 |     { | ||
| 43 | 4 |         if (!$this->hasRole($role)) { | |
| 44 | 4 | $this->roles[] = strtoupper($role); | |
| 45 | } | ||
| 46 | |||
| 47 | 4 | return $this; | |
| 48 | } | ||
| 49 | |||
| 50 | /** | ||
| 51 |      * {@inheritdoc} | ||
| 52 | */ | ||
| 53 | 5 | public function getId() | |
| 54 |     { | ||
| 55 | 5 | return $this->id; | |
| 56 | } | ||
| 57 | |||
| 58 | /** | ||
| 59 |      * {@inheritdoc} | ||
| 60 | */ | ||
| 61 | 5 | public function getName() | |
| 64 | } | ||
| 65 | |||
| 66 | /** | ||
| 67 |      * {@inheritdoc} | ||
| 68 | */ | ||
| 69 | 4 | public function hasRole($role) | |
| 70 |     { | ||
| 71 | 4 | return in_array(strtoupper($role), $this->roles, true); | |
| 72 | } | ||
| 73 | |||
| 74 | /** | ||
| 75 |      * {@inheritdoc} | ||
| 76 | */ | ||
| 77 | 4 | public function getRoles() | |
| 78 |     { | ||
| 79 | 4 | return $this->roles; | |
| 80 | } | ||
| 81 | |||
| 82 | /** | ||
| 83 |      * {@inheritdoc} | ||
| 84 | */ | ||
| 85 | 2 | public function removeRole($role) | |
| 93 | } | ||
| 94 | |||
| 95 | /** | ||
| 96 |      * {@inheritdoc} | ||
| 97 | */ | ||
| 98 | 4 | public function setName($name) | |
| 99 |     { | ||
| 100 | 4 | $this->name = $name; | |
| 101 | |||
| 102 | 4 | return $this; | |
| 103 | } | ||
| 104 | |||
| 105 | /** | ||
| 106 |      * {@inheritdoc} | ||
| 107 | */ | ||
| 108 | public function setRoles(array $roles) | ||
| 113 | } | ||
| 114 | } | ||
| 115 |