Completed
Push — master ( d7cf61...9620dc )
by Nicolas
03:49 queued 12s
created

GeneratorPath::getPath()   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
10 120
    public function __construct($config)
11
    {
12 120
        if (is_array($config)) {
13 117
            $this->path = $config['path'];
14 117
            $this->generate = $config['generate'];
15 117
            $this->namespace = $config['namespace'] ?? $config['path'];
0 ignored issues
show
Bug introduced by
The property namespace does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
16
17 117
            return;
18
        }
19 5
        $this->path = $config;
20 5
        $this->generate = (bool) $config;
21 5
        $this->namespace = $config;
22 5
    }
23
24 120
    public function getPath()
25
    {
26 120
        return $this->path;
27
    }
28
29 120
    public function generate() : bool
30
    {
31 120
        return $this->generate;
32
    }
33
34
    public function getNamespace()
35
    {
36
        return $this->namespace;
37
    }
38
}
39