Breadcrumb::hideLabel()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * A class for breadcrumb concept hierarchy paths
5
 */
6
class Breadcrumb
7
{
8
    /** a label for the term doesn't need to be a prefLabel */
9
    private $prefLabel;
10
    /** uri of the concept */
11
    private $uri;
12
    /** an array of narrower concepts */
13
    private $narrowerConcepts;
14
    /** used for storing the hidden labels */
15
    private $hiddenLabel;
16
17
    /**
18
     * Creating a new breadcrumb object requires a uri and a preflabel.
19
     * @param string $uri
20
     * @param string $prefLabel
21
     */
22
    public function __construct($uri, $prefLabel)
23
    {
24
        $this->narrowerConcepts = array();
25
        $this->uri = $uri;
26
        $this->prefLabel = $prefLabel;
27
    }
28
29
    /**
30
     * Hides the prefLabel and stores the value as a hiddenLabel.
31
     */
32
    public function hideLabel()
33
    {
34
        if (!$this->hiddenLabel) {
35
            $this->hiddenLabel = $this->prefLabel;
36
        }
37
38
        $this->prefLabel = '...';
39
    }
40
41
    /**
42
     * Used for adding narrower relationships to a Breadcrumb concept
43
     * @param Breadcrumb $concept
44
     */
45
    public function addNarrower($concept)
46
    {
47
        $this->narrowerConcepts[$concept->uri] = $concept;
48
    }
49
50
    /**
51
     * Getter for the prefLabel value
52
     */
53
    public function getPrefLabel()
54
    {
55
        return $this->prefLabel;
56
    }
57
58
    /**
59
     * Getter for the URI value
60
     */
61
    public function getUri()
62
    {
63
        return $this->uri;
64
    }
65
66
    /**
67
     * Getter for the narrower concepts array
68
     */
69
    public function getNarrowerConcepts()
70
    {
71
        return $this->narrowerConcepts;
72
    }
73
74
    /**
75
     * Getter for the hidden prefLabel value
76
     */
77
    public function getHiddenLabel()
78
    {
79
        return $this->hiddenLabel;
80
    }
81
}
82