File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232 ),
3333 'profiler.options ' => array (),
3434 'profiler.exclude-env ' => array (),
35+ 'profiler.is-exclude-all-env ' => false ,
3536 'profiler.simple_url ' => function ($ url ) {
3637 return preg_replace ('/=\d+/ ' , '' , $ url );
3738 },
Original file line number Diff line number Diff line change @@ -13,10 +13,13 @@ final class ProfilingData
1313 private $ simpleUrl ;
1414 /** @var callable|null */
1515 private $ replaceUrl ;
16+ /** @var bool */
17+ private $ isExcludeAllEnv ;
1618
1719 public function __construct (Config $ config )
1820 {
1921 $ this ->excludeEnv = isset ($ config ['profiler.exclude-env ' ]) ? (array )$ config ['profiler.exclude-env ' ] : array ();
22+ $ this ->isExcludeAllEnv = isset ($ config ['profiler.is-exclude-all-env ' ]) ? $ config ['profiler.is-exclude-all-env ' ] : false ;
2023 $ this ->simpleUrl = isset ($ config ['profiler.simple_url ' ]) ? $ config ['profiler.simple_url ' ] : null ;
2124 $ this ->replaceUrl = isset ($ config ['profiler.replace_url ' ]) ? $ config ['profiler.replace_url ' ] : null ;
2225 }
@@ -79,6 +82,10 @@ public function getProfilingData(array $profile)
7982 */
8083 private function getEnvironment (array $ env )
8184 {
85+ if ($ this ->isExcludeAllEnv ) {
86+ return array ();
87+ }
88+
8289 foreach ($ this ->excludeEnv as $ key ) {
8390 unset($ env [$ key ]);
8491 }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Xhgui \Profiler \Test ;
4+
5+ use Xhgui \Profiler \Config ;
6+ use Xhgui \Profiler \ProfilingData ;
7+
8+ class ProfilingDataTest extends TestCase
9+ {
10+ public function testExcludeAllEnv ()
11+ {
12+ $ config = new Config ([
13+ 'profiler.is-exclude-all-env ' => true
14+ ]);
15+ $ profilingData = new ProfilingData ($ config );
16+
17+ $ profile = ['example ' => 'data ' ];
18+ $ result = $ profilingData ->getProfilingData ($ profile );
19+
20+
21+ $ this ->assertEmpty ($ result ['meta ' ]['env ' ]);
22+ }
23+
24+
25+ }
You can’t perform that action at this time.
0 commit comments