Skip to content

Commit c276595

Browse files
committed
Move built in defaults to config/config.default.php
1 parent f3b7754 commit c276595

2 files changed

Lines changed: 43 additions & 34 deletions

File tree

config/config.default.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Default configuration for PHP Profiler.
4+
*
5+
* To change these, create a file called `config.php` file in the same directory
6+
* and return an array from there with your overriding settings.
7+
*/
8+
9+
use Xhgui\Profiler\Profiler;
10+
use Xhgui\Profiler\ProfilingFlags;
11+
12+
return array(
13+
'save.handler' => Profiler::SAVER_STACK,
14+
'save.handler.stack' => array(
15+
'savers' => array(
16+
Profiler::SAVER_UPLOAD,
17+
Profiler::SAVER_FILE,
18+
),
19+
'saveAll' => false,
20+
),
21+
'save.handler.file' => array(
22+
'filename' => sys_get_temp_dir() . '/xhgui.data.jsonl',
23+
),
24+
'profiler.enable' => function () {
25+
return true;
26+
},
27+
'profiler.flags' => array(
28+
ProfilingFlags::CPU,
29+
ProfilingFlags::MEMORY,
30+
ProfilingFlags::NO_BUILTINS,
31+
ProfilingFlags::NO_SPANS,
32+
),
33+
'profiler.options' => array(),
34+
'profiler.exclude-env' => array(),
35+
'profiler.simple_url' => function ($url) {
36+
return preg_replace('/=\d+/', '', $url);
37+
},
38+
'profiler.replace_url' => null,
39+
);

src/Config.php

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
class Config implements ArrayAccess
99
{
1010
/** @var array */
11-
private $config;
11+
private $config = array();
1212

1313
public function __construct(array $config = array())
1414
{
15-
$this->config = $this->getDefaultConfig();
15+
$this->loadDefaultConfig();
1616
if ($config) {
1717
$this->merge($config);
1818
}
@@ -66,38 +66,8 @@ public function offsetUnset($offset)
6666
unset($this->config[$offset]);
6767
}
6868

69-
/**
70-
* @return array
71-
*/
72-
private function getDefaultConfig()
69+
private function loadDefaultConfig()
7370
{
74-
return array(
75-
'save.handler' => Profiler::SAVER_STACK,
76-
'save.handler.stack' => array(
77-
'savers' => array(
78-
Profiler::SAVER_UPLOAD,
79-
Profiler::SAVER_FILE,
80-
),
81-
'saveAll' => false,
82-
),
83-
'save.handler.file' => array(
84-
'filename' => sys_get_temp_dir() . '/xhgui.data.jsonl',
85-
),
86-
'profiler.enable' => function () {
87-
return true;
88-
},
89-
'profiler.flags' => array(
90-
ProfilingFlags::CPU,
91-
ProfilingFlags::MEMORY,
92-
ProfilingFlags::NO_BUILTINS,
93-
ProfilingFlags::NO_SPANS,
94-
),
95-
'profiler.options' => array(),
96-
'profiler.exclude-env' => array(),
97-
'profiler.simple_url' => function ($url) {
98-
return preg_replace('/=\d+/', '', $url);
99-
},
100-
'profiler.replace_url' => null,
101-
);
71+
$this->load(__DIR__ . '/../config/config.default.php');
10272
}
10373
}

0 commit comments

Comments
 (0)