Completed
Push — FVSv2 ( daaaca...306d39 )
by Patrick
01:42
created

VolunteerObject::__get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
class VolunteerObject
3
{
4
    protected $dbData;
5
6
    public function __construct($id, $dbData, $tableName, $index)
7
    {
8
        if($dbData === null)
9
        {
10
            $dataTable = DataSetFactory::getDataTableByNames('fvs', $tableName);
11
            $filter = new \Data\Filter($index.' eq '.$id);
12
            $objs = $dataTable->read($filter);
13
            if(empty($objs))
14
            {
15
                throw new Exception('Unable to locate object with ID '.$id);
16
            }
17
            $dbData = $objs[0];
18
        }
19
        $this->dbData = $dbData;
20
    }
21
22
    public function __get($propName)
23
    {
24
        return $this->dbData[$propName];
25
    }
26
}
27