Passed
Pull Request — master (#48)
by Arman
03:56
created

Setup::setEnv()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * Quantum PHP Framework
5
 *
6
 * An open source software development framework for PHP
7
 *
8
 * @package Quantum
9
 * @author Arman Ag. <[email protected]>
10
 * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
11
 * @link http://quantum.softberg.org/
12
 * @since 2.6.0
13
 */
14
15
namespace Quantum\Loader;
16
17
use Quantum\Exceptions\ConfigException;
18
19
/**
20
 * Class Setup
21
 * @package Quantum\Loader
22
 */
23
class Setup
24
{
25
    /**
26
     * @var bool
27
     */
28
    protected $hierarchical = false;
29
30
    /**
31
     * @var string|null
32
     */
33
    protected $module;
34
35
    /**
36
     * @var string|null
37
     */
38
    protected $pathPrefix;
39
40
    /**
41
     * @var string|null
42
     */
43
    protected $fileName;
44
45
    /**
46
     * @var string
47
     */
48
    protected $exceptionMessage;
49
50
    /**
51
     * Setup constructor.
52
     * @param string|null $pathPrefix
53
     * @param string|null $fileName
54
     * @param bool $hierarchical
55
     * @param string|null $module
56
     * @param string $exceptionMessage
57
     */
58
    public function __construct(string $pathPrefix = null, string $fileName = null, bool $hierarchical = true, string $module = null, string $exceptionMessage = ConfigException::CONFIG_FILE_NOT_FOUND)
59
    {
60
        $this->pathPrefix = $pathPrefix;
61
        $this->fileName = $fileName;
62
        $this->hierarchical = $hierarchical;
63
        $this->module = $module ?: current_module();
64
        $this->exceptionMessage = $exceptionMessage;
65
    }
66
67
    /**
68
     * Sets the path prefix
69
     * @param string $pathPrefix
70
     * @return $this
71
     */
72
    public function setPathPrefix(string $pathPrefix): Setup
73
    {
74
        $this->pathPrefix = $pathPrefix;
75
        return $this;
76
    }
77
78
    /**
79
     * Gets the path prefix
80
     * @return string|null
81
     */
82
    public function getPathPrefix(): ?string
83
    {
84
        return $this->pathPrefix;
85
    }
86
87
    /**
88
     * Set the filename
89
     * @param string $fileName
90
     * @return $this
91
     */
92
    public function setFilename(string $fileName): Setup
93
    {
94
        $this->fileName = $fileName;
95
        return $this;
96
    }
97
98
    /**
99
     * Gets the filename
100
     * @return string|null
101
     */
102
    public function getFilename(): ?string
103
    {
104
        return $this->fileName;
105
    }
106
107
    /**
108
     * Sets the module
109
     * @param string $module
110
     * @return $this
111
     */
112
    public function setModule(string $module): Setup
113
    {
114
        $this->module = $module;
115
        return $this;
116
    }
117
118
    /**
119
     * Gets the module
120
     * @return string|null
121
     */
122
    public function getModule(): ?string
123
    {
124
        return $this->module;
125
    }
126
127
    /**
128
     * Sets the exception message
129
     * @param string $exceptionMessage
130
     * @return $this
131
     */
132
    public function setExceptionMessage(string $exceptionMessage): Setup
133
    {
134
        $this->exceptionMessage = $exceptionMessage;
135
        return $this;
136
    }
137
138
    /**
139
     * Gets the exception message
140
     * @return string
141
     */
142
    public function getExceptionMessage(): string
143
    {
144
        return $this->exceptionMessage;
145
    }
146
147
    /**
148
     * Set the hierarchy
149
     * @param bool $hierarchy
150
     * @return $this
151
     */
152
    public function setHierarchy(bool $hierarchy): Setup
153
    {
154
        $this->hierarchical = $hierarchy;
155
        return $this;
156
    }
157
158
    /**
159
     * Gets the hierarchy
160
     * @return bool
161
     */
162
    public function getHierarchy(): bool
163
    {
164
        return $this->hierarchical;
165
    }
166
}