Completed
Push — FVSv2 ( 427c44...e6ffd8 )
by Patrick
01:43
created

VolunteerObject::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 4
dl 0
loc 15
rs 9.7666
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