Membership::getMutations()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
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\RepeatableIdCollection;
8
use Blackmine\Model\Identity;
9
use Blackmine\Model\Project\Project;
10
use Blackmine\Mutator\MutableInterface;
11
use Blackmine\Mutator\Mutation\RenameKeyMutation;
12
use Blackmine\Repository\Projects\Memberships;
13
14
/**
15
 * @method void setProject(Project $project)
16
 * @method void setUser(User $user)
17
 * @method void setGroup(Group $group)
18
 * @method void setRoles(RepeatableIdCollection $roles)
19
 *
20
 * @method void addRole(Role $role)
21
 * @method void removeRole(Role $role)
22
 */
23
class Membership extends Identity implements MutableInterface
24
{
25
    public const ENTITY_NAME = "membership";
26
27
    protected Project $project;
28
    protected ?User $user;
29
    protected ?Group $group;
30
31
    protected RepeatableIdCollection $roles;
32
33
    public static function getRepositoryClass(): ?string
34
    {
35
        return Memberships::class;
36
    }
37
38
    public function getMutations(): array
39
    {
40
        return [
41
            "user" => [RenameKeyMutation::class => ["user_id"]],
42
            "group" => [RenameKeyMutation::class => ["group_id"]],
43
            "roles" => [RenameKeyMutation::class => ["role_ids"]]
44
        ];
45
    }
46
}
47