Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/config.default.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
),
'profiler.options' => array(),
'profiler.exclude-env' => array(),
'profiler.is-exclude-all-env' => false,
'profiler.simple_url' => function ($url) {
return preg_replace('/=\d+/', '', $url);
},
Expand Down
7 changes: 7 additions & 0 deletions src/ProfilingData.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ final class ProfilingData
private $simpleUrl;
/** @var callable|null */
private $replaceUrl;
/** @var bool */
private $isExcludeAllEnv;

public function __construct(Config $config)
{
$this->excludeEnv = isset($config['profiler.exclude-env']) ? (array)$config['profiler.exclude-env'] : array();
$this->isExcludeAllEnv = isset($config['profiler.is-exclude-all-env']) ? $config['profiler.is-exclude-all-env'] : false;
$this->simpleUrl = isset($config['profiler.simple_url']) ? $config['profiler.simple_url'] : null;
$this->replaceUrl = isset($config['profiler.replace_url']) ? $config['profiler.replace_url'] : null;
}
Expand Down Expand Up @@ -79,6 +82,10 @@ public function getProfilingData(array $profile)
*/
private function getEnvironment(array $env)
{
if($this->isExcludeAllEnv) {
return array();
}

foreach ($this->excludeEnv as $key) {
unset($env[$key]);
}
Expand Down
25 changes: 25 additions & 0 deletions tests/ProfilingDataTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Xhgui\Profiler\Test;

use Xhgui\Profiler\Config;
use Xhgui\Profiler\ProfilingData;

class ProfilingDataTest extends TestCase
{
public function testExcludeAllEnv()
{
$config = new Config([
'profiler.is-exclude-all-env' => true
]);
$profilingData = new ProfilingData($config);

$profile = ['example' => 'data'];
$result = $profilingData->getProfilingData($profile);


$this->assertEmpty($result['meta']['env']);
}


}