Completed
Push — master ( 0e1155...c9e2d7 )
by Kristof
11s
created

LabelImporter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 0
cbo 3
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A importLabels() 0 21 3
1
<?php
2
3
namespace CultuurNet\UDB3;
4
5
class LabelImporter
6
{
7
    /**
8
     * @param \CultureFeed_Cdb_Item_Base $item
9
     * @param $jsonLD
10
     */
11
    public function importLabels(\CultureFeed_Cdb_Item_Base $item, $jsonLD)
12
    {
13
        $labelCollection = LabelCollection::fromKeywords(
14
            $item->getKeywords(true)
15
        );
16
17
        $visibleLabels = $labelCollection->filter(
18
            function (Label $label) {
19
                return $label->isVisible();
20
            }
21
        )->toStrings();
22
23
        $hiddenLabels = $labelCollection->filter(
24
            function (Label $label) {
25
                return !$label->isVisible();
26
            }
27
        )->toStrings();
28
29
        empty($visibleLabels) ?: $jsonLD->labels = $visibleLabels;
30
        empty($hiddenLabels) ?: $jsonLD->hiddenLabels = $hiddenLabels;
31
    }
32
}
33