File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,22 @@ public function toArray()
2626 return $ this ->config ;
2727 }
2828
29+ /**
30+ * Create config from defaults, and merge config/config.php if the file exists
31+ *
32+ * @return Config
33+ */
34+ public static function create ()
35+ {
36+ $ configDir = dirname (__DIR__ ) . '/config ' ;
37+ $ config = new self ();
38+ if (file_exists ($ file = $ configDir . '/config.php ' )) {
39+ $ config ->load ($ file );
40+ }
41+
42+ return $ config ;
43+ }
44+
2945 /**
3046 * Load a config file, merge with the currently loaded configuration.
3147 */
Original file line number Diff line number Diff line change @@ -20,6 +20,12 @@ public function testLoadConfig()
2020 $ this ->assertEquals (Profiler::SAVER_UPLOAD , $ config ['save.handler ' ]);
2121 }
2222
23+ public function testFromFile ()
24+ {
25+ $ config = Config::create ();
26+ $ this ->assertEquals (Profiler::SAVER_STACK , $ config ['save.handler ' ]);
27+ }
28+
2329 /**
2430 * @expectedException \Xhgui\Profiler\Exception\ProfilerException
2531 * @expectedExceptionMessage Config did not return an array
You can’t perform that action at this time.
0 commit comments