Configuration::prependNamespace()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Nip\Dispatcher\Configuration;
5
6
/**
7
 * Class Configuration
8
 * @package Nip\Records\Locator
9
 */
10
class Configuration
11
{
12
    protected array $namespaces;
13
14
    /**
15
     */
16
    public function __construct()
17
    {
18
        if (function_exists('app') && app()->has('app')) {
19
            $this->namespaces[] = app('app')->getRootNamespace();
20
        } else {
21
            $this->namespaces[] = '';
22
        }
23
    }
24
25
26
    /**
27
     * @param $namespace
28
     */
29
    public function prependNamespace($namespace)
30
    {
31
        array_unshift($this->namespaces, $namespace);
32
    }
33
34
    /**
35
     * @param $namespace
36
     */
37
    public function addNamespace($namespace)
38
    {
39
        $this->namespaces[] = $namespace;
40
    }
41
42
    /**
43
     * @return array
44
     */
45
    public function getNamespaces(): array
46
    {
47
        return $this->namespaces;
48
    }
49
50
    /**
51
     * @return bool
52
     */
53
    public function hasNamespaces()
54
    {
55
        return count($this->namespaces) > 0;
56
    }
57
58
    /**
59
     * @param array $namespaces
60
     */
61
    public function setNamespaces(array $namespaces): void
62
    {
63
        $this->namespaces = $namespaces;
64
    }
65
}
66