Completed
Push — master ( bf46e5...ba9152 )
by Henri
05:34
created

ConceptPropertyValueLiteral::getContainsHtml()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * Class for handling concept property values.
5
 */
6
class ConceptPropertyValueLiteral
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
{
8
    /** the literal object for the property value */
9
    private $literal;
10
    /** property type */
11
    private $type;
12
13
    public function __construct($literal, $prop)
14
    {
15
        $this->literal = $literal;
16
        $this->type = $prop;
17
    }
18
19
    public function __toString()
20
    {
21
        if ($this->getLabel() === null) {
22
            return "";
23
        }
24
25
        return $this->getLabel();
26
    }
27
28
    public function getLang()
29
    {
30
        return $this->literal->getLang();
31
    }
32
33
    public function getType()
34
    {
35
        return $this->type;
36
    }
37
38
    public function getContainsHtml() {
39
        return preg_match("/\/[a-z]*>/i", $this->literal->getValue()) != 0;
40
    }
41
42
    public function getLabel()
43
    {
44
        // if the property is a date object converting it to a human readable representation.
45
        if ($this->literal instanceof EasyRdf_Literal_Date) {
46
            try {
47
                $val = $this->literal->getValue();
48
                return Punic\Calendar::formatDate($val, 'short');
49
            } catch (Exception $e) {
50
                trigger_error($e->getMessage(), E_USER_WARNING);
51
                return (string) $this->literal;
52
            }
53
        }
54
        return $this->literal->getValue();
55
    }
56
57
    public function getUri()
58
    {
59
        return null;
60
    }
61
62
    public function getNotation()
63
    {
64
        return null;
65
    }
66
67
}
68