Completed
Push — master ( d0020c...40116c )
by wen
05:19
created

Factory::makeFromUri()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
4
namespace Sco\Admin\Config;
5
6
7
class Factory
8
{
9
    protected $config = null;
10
11
    public function __construct()
12
    {
13
14
    }
15
16
    public function makeFromUri($uri)
17
    {
18
        $name = str_replace('/', '.', $uri);
19
        return $this->make($name);
20
    }
21
22
    public function make($name)
23
    {
24
        $config = null;
25
        $options = $this->getConfigOptions($name);
26
        if ($options) {
27
            $config = new Config($options);
28
        }
29
        $this->config = $config;
30
31
        return $config;
32
    }
33
34
    protected function getConfigOptions($name)
35
    {
36
        $name = config('admin.model_config_dir') . '.' . $name;
37
        return config($name);
38
    }
39
}