Completed
Pull Request — master (#400)
by
unknown
10:10
created

getLabelsToKeepIfAlreadyOnOffer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace CultuurNet\UDB3\Offer\Commands;
4
5
use CultuurNet\UDB3\Model\ValueObject\Taxonomy\Label\Label;
6
use CultuurNet\UDB3\Model\ValueObject\Taxonomy\Label\Labels;
7
use CultuurNet\UDB3\Security\LabelSecurityInterface;
8
use ValueObjects\StringLiteral\StringLiteral;
9
10
abstract class AbstractImportLabels extends AbstractCommand implements LabelSecurityInterface
11
{
12
    /**
13
     * @var Labels
14
     */
15
    private $labels;
16
17
    /**
18
     * @var Labels
19
     */
20
    private $labelsToKeepIfAlreadyOnOffer;
21
22
    /**
23
     * @param string $itemId
24
     * @param Labels $labels
25
     */
26
    public function __construct($itemId, Labels $labels)
27
    {
28
        parent::__construct($itemId);
29
        $this->labels = $labels;
30
        $this->labelsToKeepIfAlreadyOnOffer = new Labels();
31
    }
32
33
    public function withLabelsToKeepIfAlreadyOnOffer(Labels $labels): self
34
    {
35
        $c = clone $this;
36
        $c->labelsToKeepIfAlreadyOnOffer = $labels;
37
        return $c;
38
    }
39
40
    public function getLabelsToKeepIfAlreadyOnOffer(): Labels
41
    {
42
        return $this->labelsToKeepIfAlreadyOnOffer;
43
    }
44
45
    /**
46
     * @return Labels
47
     */
48
    public function getLabels()
49
    {
50
        return $this->labels;
51
    }
52
53
    /**
54
     * @inheritdoc
55
     */
56
    public function getNames()
57
    {
58
        return array_map(
59
            function (Label $label) {
60
                return new StringLiteral($label->getName()->toString());
61
            },
62
            $this->getLabels()->toArray()
63
        );
64
    }
65
}
66