| Total Complexity | 9 |
| Total Lines | 93 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | class Role implements RoleInterface |
||
| 14 | { |
||
| 15 | /** @var string */ |
||
| 16 | private string $id; |
||
| 17 | |||
| 18 | /** @var RoleInterface[] */ |
||
| 19 | private array $parents; |
||
| 20 | |||
| 21 | /** @var RoleInterface[] */ |
||
| 22 | private array $children; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Role constructor. |
||
| 26 | * |
||
| 27 | * @param string $id |
||
| 28 | */ |
||
| 29 | public function __construct(string $id) |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @inheritdoc |
||
| 38 | */ |
||
| 39 | public function __toString(): string |
||
| 40 | { |
||
| 41 | return $this->id; |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @inheritdoc |
||
| 46 | */ |
||
| 47 | public function addParent(RoleInterface $role): RoleInterface |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @inheritdoc |
||
| 56 | */ |
||
| 57 | public function removeParent(RoleInterface $role): RoleInterface |
||
| 58 | { |
||
| 59 | unset($this->parents[(string)$role]); |
||
| 60 | |||
| 61 | return $this; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @inheritdoc |
||
| 66 | */ |
||
| 67 | public function parents(): array |
||
| 68 | { |
||
| 69 | return $this->parents; |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @inheritdoc |
||
| 74 | */ |
||
| 75 | public function hasParents(): bool |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @inheritdoc |
||
| 82 | */ |
||
| 83 | public function addChildren(RoleInterface $role): RoleInterface |
||
| 84 | { |
||
| 85 | $this->children[(string)$role] = $role; |
||
| 86 | |||
| 87 | return $this; |
||
| 88 | } |
||
| 89 | |||
| 90 | /** |
||
| 91 | * @inheritdoc |
||
| 92 | */ |
||
| 93 | public function removeChildren(RoleInterface $role): RoleInterface |
||
| 94 | { |
||
| 95 | unset($this->children[(string)$role]); |
||
| 96 | |||
| 97 | return $this; |
||
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @inheritdoc |
||
| 102 | */ |
||
| 103 | public function children(): array |
||
| 106 | } |
||
| 107 | } |
||
| 108 |