Completed
Push — master ( 5d8fdd...46e3e5 )
by Marco
01:37
created

Configuration::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
ccs 2
cts 2
cp 1
rs 9.4285
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php namespace Comodojo\Foundation\Base;
2
3
/**
4
 * @package     Comodojo Foundation
5
 * @author      Marco Giovinazzi <[email protected]>
6
 * @license     MIT
7
 *
8
 * LICENSE:
9
 *
10
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
16
 * THE SOFTWARE.
17
 */
18
19
class Configuration {
20
21
    use ConfigurationParametersTrait;
22
23
    /**
24
     * Create a configuration object from array of values
25
     *
26
     * @param array $configuration
27
     * @return self
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
28
     */
29 8
    public function __construct(array $configuration = []) {
30
31 8
        $this->parameters = array_merge($this->parameters, $configuration);
32
33 8
    }
34
35
    /**
36
     * Check if a property is defined
37
     *
38
     * @deprecated
39
     * @see Configuration::has()
40
     *
41
     * @param string $property
42
     * @return bool
43
     */
44 2
    public function isDefined($property) {
45
46 2
        return $this->has($property);
47
48
    }
49
50
    /**
51
     * Merge a bundle of properties into actual configuration model
52
     *
53
     * @param array $properties
54
     * @return self
55
     */
56 1
    public function merge(array $properties) {
57
58 1
        $this->parameters = array_replace($this->parameters, $properties);
59
60 1
        return $this;
61
62
    }
63
64 1
    public static function create(array $configuration = []) {
65
66 1
        return new Configuration($configuration);
67
68
    }
69
70
}
71