VocabularyCategory   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getVocabularies() 0 6 2
A getTitle() 0 7 3
A __construct() 0 9 2
1
<?php
2
3
/**
4
 * Groups vocabularies of a specific category into a DataObject.
5
 */
6
class VocabularyCategory extends DataObject
7
{
8
    public function __construct($model, $resource)
9
    {
10
        if (!($model instanceof Model)) {
11
            throw new InvalidArgumentException('Invalid constructor parameter given to DataObject.');
12
        }
13
14
        $this->model = $model;
15
        $this->resource = $resource;
16
        $this->order = array();
17
    }
18
19
    /**
20
     * Returns all vocabularies in the category.
21
     */
22
    public function getVocabularies()
23
    {
24
        if ($this->resource) {
25
            return $this->model->getVocabulariesInCategory($this->resource);
26
        }
27
        return $this->model->getVocabularies();
28
    }
29
30
    /**
31
     * Returns the title of the category.
32
     */
33
    public function getTitle()
34
    {
35
        if ($this->resource) {
36
            $label = $this->resource->label($this->getLang());
37
            return is_null($label) ? $this->resource->localName() : $label->getValue();
38
        }
39
        return $this->model->getText('Vocabularies');
40
    }
41
42
}
43