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

LabelImporter::importLabels()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 21
rs 9.3142
cc 3
eloc 13
nc 4
nop 2
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