Completed
Push — master ( 2e4876...a75670 )
by Nicolas
04:01
created

GeneratorPath   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 40
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 2
A getPath() 0 4 1
A generate() 0 4 1
A getNamespace() 0 4 1
A convertPathToNamespace() 0 4 1
1
<?php
2
3
namespace Nwidart\Modules\Support\Config;
4
5
class GeneratorPath
6
{
7
    private $path;
8
    private $generate;
9
    private $namespace;
10
11 131
    public function __construct($config)
12
    {
13 131
        if (is_array($config)) {
14 128
            $this->path = $config['path'];
15 128
            $this->generate = $config['generate'];
16 128
            $this->namespace = $config['namespace'] ?? $this->convertPathToNamespace($config['path']);
17
18 128
            return;
19
        }
20 5
        $this->path = $config;
21 5
        $this->generate = (bool) $config;
22 5
        $this->namespace = $config;
23 5
    }
24
25 131
    public function getPath()
26
    {
27 131
        return $this->path;
28
    }
29
30 130
    public function generate() : bool
31
    {
32 130
        return $this->generate;
33
    }
34
35 127
    public function getNamespace()
36
    {
37 127
        return $this->namespace;
38
    }
39
40 128
    private function convertPathToNamespace($path)
41
    {
42 128
        return str_replace('/', '\\', $path);
43
    }
44
}
45