Skip to content

Commit 769c8a5

Browse files
committed
Add default config values to Config class
1 parent 1a7a8ff commit 769c8a5

1 file changed

Lines changed: 44 additions & 1 deletion

File tree

src/Config.php

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ class Config implements ArrayAccess
1111

1212
public function __construct(array $config = array())
1313
{
14-
$this->config = $config;
14+
$this->config = $this->getDefaultConfig();
15+
if ($config) {
16+
$this->merge($config);
17+
}
18+
}
19+
20+
private function merge(array $config)
21+
{
22+
$this->config = array_replace($this->config, $config);
1523
}
1624

1725
public function offsetExists($offset)
@@ -33,4 +41,39 @@ public function offsetUnset($offset)
3341
{
3442
unset($this->config[$offset]);
3543
}
44+
45+
/**
46+
* @return array
47+
*/
48+
private function getDefaultConfig()
49+
{
50+
return array(
51+
'save.handler' => Profiler::SAVER_STACK,
52+
'save.handler.stack' => array(
53+
'savers' => array(
54+
Profiler::SAVER_UPLOAD,
55+
Profiler::SAVER_FILE,
56+
),
57+
'saveAll' => false,
58+
),
59+
'save.handler.file' => array(
60+
'filename' => sys_get_temp_dir() . '/xhgui.data.jsonl',
61+
),
62+
'profiler.enable' => function () {
63+
return true;
64+
},
65+
'profiler.flags' => array(
66+
ProfilingFlags::CPU,
67+
ProfilingFlags::MEMORY,
68+
ProfilingFlags::NO_BUILTINS,
69+
ProfilingFlags::NO_SPANS,
70+
),
71+
'profiler.options' => array(),
72+
'profiler.exclude-env' => array(),
73+
'profiler.simple_url' => function ($url) {
74+
return preg_replace('/=\d+/', '', $url);
75+
},
76+
'profiler.replace_url' => null,
77+
);
78+
}
3679
}

0 commit comments

Comments
 (0)