Factory::make()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 2 Features 0
Metric Value
eloc 4
c 2
b 2
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
namespace LWS\Import;
4
5
class Factory
6
{
7
    public function __construct()
8
    {
9
        $this->namespace = config('import.namespace');
0 ignored issues
show
Bug Best Practice introduced by
The property namespace does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
10
    }
11
12
    public function make($source)
13
    {
14
        $source = ucfirst(strtolower($source));
15
        $name = $this->namespace.'\\'.$source;
16
17
        if (class_exists($name)) {
18
            return new $name();
19
        }
20
    }
21
}
22