Group::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
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