Group   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getRepositoryClass() 0 3 1
A getMutations() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Blackmine\Model\User;
6
7
use Blackmine\Collection\IdentityCollection;
8
use Blackmine\Collection\RepeatableIdCollection;
9
use Blackmine\Model\NamedIdentity;
10
use Blackmine\Mutator\MutableInterface;
11
use Blackmine\Mutator\Mutation\RenameKeyMutation;
12
use Blackmine\Repository\Users\Groups;
13
14
/**
15
 * @method void setUsers(RepeatableIdCollection $users)
16
 * @method void setMemberships(IdentityCollection $memberships)
17
 *
18
 * @method void addUser(User $user)
19
 * @method void removeUser(User $user)
20
 * @method void addMembership(Membership $membership)
21
 * @method void removeMembership(Membership $membership)
22
 *
23
 * @method RepeatableIdCollection getUsers()
24
 * @method IdentityCollection getMemberships()
25
 */
26
class Group extends NamedIdentity implements MutableInterface
27
{
28
    public const ENTITY_NAME = "group";
29
30
    protected RepeatableIdCollection $users;
31
    protected IdentityCollection $memberships;
32
33
    public function __construct(protected ?int $id = null, protected ?string $name = null)
34
    {
35
        $this->users = new RepeatableIdCollection();
36
        $this->memberships = new IdentityCollection();
37
    }
38
39
    public static function getRepositoryClass(): ?string
40
    {
41
        return Groups::class;
42
    }
43
44
    public function getMutations(): array
45
    {
46
        return [
47
            "users" => [RenameKeyMutation::class => ["user_ids"]]
48
        ];
49
    }
50
}
51