Completed
Pull Request — master (#236)
by Luc
04:54
created

AbstractLabelCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
3
namespace CultuurNet\UDB3\Organizer\Commands;
4
5
use CultuurNet\UDB3\Offer\Commands\AuthorizableCommandInterface;
6
use CultuurNet\UDB3\Role\ValueObjects\Permission;
7
use CultuurNet\UDB3\Security\LabelSecurityInterface;
8
use ValueObjects\Identity\UUID;
9
10
abstract class AbstractLabelCommand extends AbstractOrganizerCommand implements AuthorizableCommandInterface, LabelSecurityInterface
11
{
12
    /**
13
     * @var UUID
14
     */
15
    private $labelId;
16
17
    /**
18
     * @var bool
19
     */
20
    private $allwaysAllowed = false;
21
22
    /**
23
     * @param string $organizerId
24
     * @param UUID $labelId
25
     */
26
    public function __construct(
27
        $organizerId,
28
        UUID $labelId
29
    ) {
30
        parent::__construct($organizerId);
31
        $this->labelId = $labelId;
32
    }
33
34
    /**
35
     * @param bool $alwaysAllowed
36
     * @return AbstractLabelCommand
37
     */
38
    public function withAlwaysAllowed($alwaysAllowed)
39
    {
40
        $c = clone $this;
41
        $c->allwaysAllowed = $alwaysAllowed;
42
        return $c;
43
    }
44
45
    /**
46
     * @return UUID
47
     */
48
    public function getLabelId()
49
    {
50
        return $this->labelId;
51
    }
52
53
    /**
54
     * @inheritdoc
55
     */
56
    public function getItemId()
57
    {
58
        return $this->getOrganizerId();
59
    }
60
61
    /**
62
     * @inheritdoc
63
     */
64
    public function getPermission()
65
    {
66
        return Permission::AANBOD_BEWERKEN();
67
    }
68
69
    /**
70
     * @inheritdoc
71
     */
72
    public function isIdentifiedByUuid()
73
    {
74
        return true;
75
    }
76
77
    /**
78
     * @inheritdoc
79
     */
80
    public function getName()
81
    {
82
        return null;
83
    }
84
85
    /**
86
     * @inheritdoc
87
     */
88
    public function getUuid()
89
    {
90
        return $this->labelId;
91
    }
92
93
    /**
94
     * @inheritdoc
95
     */
96
    public function isAlwaysAllowed()
97
    {
98
        return $this->allwaysAllowed;
99
    }
100
}
101