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

GeneratorPath::generate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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