@@ -11,19 +11,27 @@ class Configuration
1111 * @var array
1212 */
1313 protected $ mapping = [];
14+ /**
15+ * @var \Noodlehaus\Config
16+ */
17+ protected $ config ;
18+
19+ /**
20+ * @param string|array $path
21+ */
22+ public function __construct ($ path )
23+ {
24+ $ this ->config = new Config ($ path );
25+ $ this ->extractMapping ($ this ->get ('level.mapping ' , []));
26+ }
1427
1528 /**
1629 * @param string|array $file
1730 * @return \PHPSemVerChecker\Configuration\Configuration
1831 */
1932 public static function fromFile ($ file )
2033 {
21- $ configuration = new Configuration ();
22- $ config = new Config ($ file );
23-
24- $ configuration ->extractMapping ($ config ->get ('level.mapping ' , []));
25-
26- return $ configuration ;
34+ return new Configuration ($ file );
2735 }
2836
2937 /**
@@ -52,4 +60,39 @@ public function getLevelMapping()
5260 {
5361 return $ this ->mapping ;
5462 }
63+
64+ /**
65+ * @see \Noodlehaus\Config::get
66+ * @param string $key
67+ * @param mixed|null $default
68+ * @return array|mixed|null
69+ */
70+ public function get ($ key , $ default = null )
71+ {
72+ return $ this ->config ->get ($ key , $ default );
73+ }
74+
75+ /**
76+ * @see \Noodlehaus\Config::set
77+ * @param string $key
78+ * @param mixed $value
79+ */
80+ public function set ($ key , $ value )
81+ {
82+ $ this ->config ->set ($ key , $ value );
83+ }
84+
85+ /**
86+ * Merge this configuration with an associative array.
87+ *
88+ * Note that dot notation is used for keys.
89+ *
90+ * @param array $data
91+ */
92+ public function merge ($ data )
93+ {
94+ foreach ($ data as $ key => $ value ) {
95+ $ this ->set ($ key , $ value );
96+ }
97+ }
5598}
0 commit comments