File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33namespace Xhgui \Profiler ;
44
55use ArrayAccess ;
6+ use Xhgui \Profiler \Exception \ProfilerException ;
67
78class Config implements ArrayAccess
89{
@@ -25,6 +26,18 @@ public function toArray()
2526 return $ this ->config ;
2627 }
2728
29+ /**
30+ * Load a config file, merge with the currently loaded configuration.
31+ */
32+ public function load ($ filename )
33+ {
34+ if (!file_exists ($ filename )) {
35+ throw new ProfilerException ("File does not exist: $ filename " );
36+ }
37+ $ config = require $ filename ;
38+ $ this ->merge ($ config );
39+ }
40+
2841 private function merge (array $ config )
2942 {
3043 $ this ->config = array_replace ($ this ->config , $ config );
Original file line number Diff line number Diff line change @@ -12,4 +12,11 @@ public function testDefaults()
1212 $ config = new Config ();
1313 $ this ->assertEquals (Profiler::SAVER_STACK , $ config ['save.handler ' ]);
1414 }
15+
16+ public function testLoadConfig ()
17+ {
18+ $ config = new Config ();
19+ $ config ->load (__DIR__ . '/Resources/config_saver.php ' );
20+ $ this ->assertEquals (Profiler::SAVER_UPLOAD , $ config ['save.handler ' ]);
21+ }
1522}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Xhgui \Profiler \Profiler ;
4+
5+ return array (
6+ 'save.handler ' => Profiler::SAVER_UPLOAD ,
7+ );
You can’t perform that action at this time.
0 commit comments