LabelSkosXL::getLiteral()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
class LabelSkosXL extends DataObject
4
{
5
    public function __construct($model, $resource)
6
    {
7
        parent::__construct($model, $resource);
8
    }
9
10
    public function getPrefLabel()
11
    {
12
        $label = null;
13
        $labels = $this->resource->allResources('skosxl:prefLabel');
14
        foreach ($labels as $labres) {
15
            $label = $labres->getLiteral('skosxl:literalForm');
16
            if ($label->getLang() == $this->clang) {
0 ignored issues
show
Bug Best Practice introduced by
The property clang does not exist on LabelSkosXL. Did you maybe forget to declare it?
Loading history...
17
                return $label;
18
            }
19
        }
20
        return $label;
21
    }
22
23
    public function getProperties()
24
    {
25
        $ret = array();
26
        $props = $this->resource->properties();
27
        foreach ($props as $prop) {
28
            if ($prop !== 'rdf:type' && $prop !== 'skosxl:literalForm') {
29
                // make sure to use the correct gettext keys for DC namespace
30
                $propkey = str_starts_with($prop, 'dc11:') ?
31
                    str_replace('dc11:', 'dc:', $prop) : $prop;
32
                $ret[$propkey] = $this->resource->get($prop);
33
            }
34
        }
35
        return $ret;
36
    }
37
38
    public function getLiteral()
39
    {
40
        return $this->resource->getLiteral('skosxl:literalForm')->getValue();
41
    }
42
43
    public function __toString()
44
    {
45
        return $this->resource->getLiteral('skosxl:literalForm')->getValue();
46
    }
47
}
48