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

AbstractLabelCommand::withAlwaysAllowed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace CultuurNet\UDB3\Offer\Commands;
4
5
use CultuurNet\UDB3\Label;
6
use CultuurNet\UDB3\Security\LabelSecurityInterface;
7
use ValueObjects\String\String as StringLiteral;
8
9
abstract class AbstractLabelCommand extends AbstractCommand implements LabelSecurityInterface
10
{
11
    /**
12
     * @var Label
13
     */
14
    protected $label;
15
16
    /**
17
     * @var bool
18
     */
19
    private $alwaysAllowed = false;
20
21
    /**
22
     * @param $itemId
23
     *  The id of the item that is targeted by the command.
24
     *
25
     * @param Label $label
26
     *  The label that is used in the command.
27
     */
28
    public function __construct($itemId, Label $label)
29
    {
30
        parent::__construct($itemId);
31
        $this->label = $label;
32
        $this->itemId = $itemId;
33
    }
34
35
    /**
36
     * @param bool $alwaysAllowed
37
     * @return AbstractLabelCommand
38
     */
39
    public function withAlwaysAllowed($alwaysAllowed)
40
    {
41
        $c = clone $this;
42
        $c->alwaysAllowed = $alwaysAllowed;
43
        return $c;
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getItemId()
50
    {
51
        return $this->itemId;
52
    }
53
54
    /**
55
     * @return Label
56
     */
57
    public function getLabel()
58
    {
59
        return $this->label;
60
    }
61
62
    /**
63
     * @inheritdoc
64
     */
65
    public function isIdentifiedByUuid()
66
    {
67
        return false;
68
    }
69
70
    /**
71
     * @inheritdoc
72
     */
73
    public function getName()
74
    {
75
        return new StringLiteral((string)$this->label);
76
    }
77
78
    /**
79
     * @inheritdoc
80
     */
81
    public function getUuid()
82
    {
83
        return null;
84
    }
85
86
    /**
87
     * @inheritdoc
88
     */
89
    public function isAlwaysAllowed()
90
    {
91
        return $this->alwaysAllowed;
92
    }
93
}
94