LabelSkosXL::getLiteral()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 2
rs 10
1
<?php
2
3
class LabelSkosXL extends DataObject
4
{
5
6
    public function __construct($model, $resource)
7
    {
8
        parent::__construct($model, $resource);
9
    }
10
11
    public function getPrefLabel() {
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
        $ret = array();
25
        $props = $this->resource->properties();
26
        foreach($props as $prop) {
27
            if ($prop !== 'rdf:type' && $prop !== 'skosxl:literalForm') {
28
                // make sure to use the correct gettext keys for DC namespace
29
                $propkey = str_starts_with($prop, 'dc11:') ?
30
                    str_replace('dc11:', 'dc:', $prop) : $prop;
31
                $ret[$propkey] = $this->resource->get($prop);
32
            }
33
        }
34
        return $ret;
35
    }
36
37
    public function getLang() {
38
      return $this->resource->getLiteral('skosxl:literalForm')->getLang();
39
    }
40
41
    public function getLiteral() {
42
        return $this->resource->getLiteral('skosxl:literalForm')->getValue();
43
    }
44
45
    public function __toString() {
46
        return $this->resource->getLiteral('skosxl:literalForm')->getValue();
47
    }
48
}
49