Completed
Push — master ( ced9b5...a42ee4 )
by Luc
15s
created

AbstractPermissionCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A getRolePermission() 0 4 1
1
<?php
2
3
namespace CultuurNet\UDB3\Role\Commands;
4
5
use CultuurNet\UDB3\Role\ValueObjects\Permission;
6
use ValueObjects\Identity\UUID;
7
8
abstract class AbstractPermissionCommand extends AbstractCommand
9
{
10
    /**
11
     * @var string
12
     */
13
    private $rolePermission;
14
15
    /**
16
     * @param UUID $uuid
17
     * @param Permission $rolePermission
18
     */
19
    public function __construct(
20
        UUID $uuid,
21
        Permission $rolePermission
22
    ) {
23
        parent::__construct($uuid);
24
25
        // The built-in serialize call does not work on Enum.
26
        // Just store them internally as string but expose as Enum.
27
        $this->rolePermission = $rolePermission->toNative();
28
    }
29
30
    /**
31
     * @return Permission
32
     */
33
    public function getRolePermission()
34
    {
35
        return Permission::fromNative($this->rolePermission);
36
    }
37
}
38