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

ConceptPropertyValueLiteral   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 2
dl 0
loc 62
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __toString() 0 8 2
A getLang() 0 4 1
A getType() 0 4 1
A getContainsHtml() 0 3 1
A getLabel() 0 14 3
A getUri() 0 4 1
A getNotation() 0 4 1
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