permissionAlreadyAttachedToRole()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Potievdev\SlimRbac\Exception;
4
5
/**
6
 * Class NotUniqueException
7
 * @package Potievdev\SlimRbac\Exception
8
 */
9
class NotUniqueException extends BaseException
10
{
11
    public static function permissionWithNameAlreadyCreated(string $permissionName): self
12
    {
13
        $e = new self("Permission with given name already created");
14
        $e->additionalParams = ['permissionName' => $permissionName];
15
16
        return $e;
17
    }
18
19
    public static function notUniqueRole(string $roleName): self
20
    {
21
        $e = new self("Role with given name already created");
22
        $e->additionalParams = ['roleName' => $roleName];
23
24
        return $e;
25
    }
26
27
    public static function permissionAlreadyAttachedToRole(string $permissionName, string $roleName): self
28
    {
29
        $e = new self("Permission already attached to role.");
30
        $e->additionalParams = ['permissionName' => $permissionName, 'roleName' => $roleName];
31
32
        return $e;
33
    }
34
35
    public static function childRoleAlreadyAttachedToGivenParentRole(string $childName, string $parentName): self
36
    {
37
        $e = new self("Child role already attached to parent role.");
38
        $e->additionalParams = ['childRoleName' => $childName, 'parentRoleName' => $parentName];
39
40
        return $e;
41
    }
42
43
    public static function roleAlreadyAssignedToUser(string $roleName, string $userId): self
44
    {
45
        $e = new self("Role already assigned to user");
46
        $e->additionalParams = ['roleName' => $roleName, 'userId' => $userId];
47
48
        return $e;
49
    }
50
51
}
52