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

AbstractPermissionCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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