PatientFactory::build()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
namespace Hospitalplugin\Entities;
3
4
class PatientFactory
5
{
6
7
    public static function build($type)
8
    {
9
        $type = 'Hospitalplugin\Entities\Patient' . $type;
10
        if (class_exists($type)) {
11
            return new $type();
12
        } else {
13
            throw new Exception("Invalid type given.");
14
        }
15
    }
16
}