GeneratorPath::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 13
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Rawilk\LaravelModules\Support\Config;
4
5
class GeneratorPath
6
{
7
    /** @var bool */
8
    private $generate;
9
10
    /** @var string */
11
    private $path;
12
13
    /** @var string */
14
    private $namespace;
15
16
    /**
17
     * @param array|string $config
18
     */
19
    public function __construct($config)
20
    {
21
        if (is_array($config)) {
22
            $this->path = $config['path'];
23
            $this->generate = $config['generate'];
24
            $this->namespace = $config['namespace'] ?? $config['path'];
25
26
            return;
27
        }
28
29
        $this->path = $config;
30
        $this->generate = (bool) $config;
31
        $this->namespace = $config;
32
    }
33
34
    public function generate(): bool
35
    {
36
        return $this->generate;
37
    }
38
39
    public function getNamespace(): string
40
    {
41
        return $this->namespace;
42
    }
43
44
    public function getPath(): string
45
    {
46
        return $this->path;
47
    }
48
}
49