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

ImportLabels   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 6
dl 0
loc 56
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getLabels() 0 4 1
A getItemId() 0 4 1
A getPermission() 0 4 1
A getNames() 0 9 1
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