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

GeneratorPath   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
dl 0
loc 34
ccs 14
cts 16
cp 0.875
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 0

4 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
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