Completed
Pull Request — master (#349)
by Luc
06:21
created

ImportLabels::__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\Model\ValueObject\Taxonomy\Label\Label;
6
use CultuurNet\UDB3\Model\ValueObject\Taxonomy\Label\Labels;
7
use CultuurNet\UDB3\Offer\Commands\AuthorizableCommandInterface;
8
use CultuurNet\UDB3\Role\ValueObjects\Permission;
9
use CultuurNet\UDB3\Security\LabelSecurityInterface;
10
use ValueObjects\StringLiteral\StringLiteral;
11
12
class ImportLabels extends AbstractOrganizerCommand implements AuthorizableCommandInterface, LabelSecurityInterface
13
{
14
    /**
15
     * @var Labels
16
     */
17
    private $labels;
18
19
    /**
20
     * @param string $organizerId
21
     * @param Labels $label
22
     */
23
    public function __construct(
24
        $organizerId,
25
        Labels $label
26
    ) {
27
        parent::__construct($organizerId);
28
        $this->labels = $label;
29
    }
30
31
    /**
32
     * @return Labels
33
     */
34
    public function getLabels()
35
    {
36
        return $this->labels;
37
    }
38
39
    /**
40
     * @inheritdoc
41
     */
42
    public function getItemId()
43
    {
44
        return $this->getOrganizerId();
45
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50
    public function getPermission()
51
    {
52
        return Permission::AANBOD_BEWERKEN();
53
    }
54
55
    /**
56
     * @inheritdoc
57
     */
58
    public function getNames()
59
    {
60
        return array_map(
61
            function (Label $label) {
62
                return new StringLiteral($label->getName()->toString());
63
            },
64
            $this->getLabels()->toArray()
65
        );
66
    }
67
}
68