VolunteerObject   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 21
c 2
b 0
f 1
dl 0
loc 43
rs 10
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDataTable() 0 3 1
A getDataFilter() 0 3 1
A __construct() 0 21 3
A __get() 0 3 1
1
<?php
2
class VolunteerObject
3
{
4
    protected $tableName;
5
    protected $dbData;
6
    protected $index;
7
    protected $id;
8
9
    public function __construct($id, $dbData, $tableName, $index)
10
    {
11
        $this->tableName = $tableName;
12
        $this->index = $index;
13
        if($dbData === null)
14
        {
15
            $dataTable = DataSetFactory::getDataTableByNames('fvs', $tableName);
16
            $filter = new \Data\Filter($index.' eq '.$id);
17
            $objs = $dataTable->read($filter);
18
            if(empty($objs))
19
            {
20
                throw new Exception('Unable to locate object with ID '.$id);
21
            }
22
            $dbData = $objs[0];
23
            $this->id = $id;
24
        }
25
        else
26
        {
27
            $this->id = $dbData[$index];
28
        }
29
        $this->dbData = $dbData;
30
    }
31
32
    public function getDataTable()
33
    {
34
        return DataSetFactory::getDataTableByNames('fvs', $this->tableName);
35
    }
36
37
    public function getDataFilter()
38
    {
39
        return new \Data\Filter($this->index.' eq '.$this->id);
40
    }
41
42
    public function __get($propName)
43
    {
44
        return $this->dbData[$propName];
45
    }
46
}
47