diff --git a/composer.json b/composer.json
index d9773f5..0279149 100644
--- a/composer.json
+++ b/composer.json
@@ -11,7 +11,8 @@
"symfony/http-kernel": "^4.4 || ^5.0 || ^6.0",
"symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0",
"symfony/config": "^4.4 || ^5.0 || ^6.0",
- "symfony/stopwatch": "^4.4 || ^5.0 || ^6.0"
+ "symfony/stopwatch": "^4.4 || ^5.0 || ^6.0",
+ "symfony/service-contracts": "^1.0 || ^2.0 || ^3.0"
},
"require-dev": {
"atoum/atoum": "^4.0",
diff --git a/src/TingBundle/DataCollector/TingCacheDataCollector.php b/src/TingBundle/DataCollector/TingCacheDataCollector.php
index 38b9568..9b69570 100644
--- a/src/TingBundle/DataCollector/TingCacheDataCollector.php
+++ b/src/TingBundle/DataCollector/TingCacheDataCollector.php
@@ -29,8 +29,9 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface;
+use Symfony\Contracts\Service\ResetInterface;
-class TingCacheDataCollector extends DataCollector implements LateDataCollectorInterface
+class TingCacheDataCollector extends DataCollector implements LateDataCollectorInterface, ResetInterface
{
/**
* @var CacheLoggerInterface|null
@@ -104,17 +105,17 @@ public function getCacheOperationsCount()
public function getCacheTotalTime()
{
- return $this->data['cache']['time'];
+ return $this->data['cache']['time'] ?? 0;
}
public function getHits()
{
- return $this->data['cache']['hits'];
+ return $this->data['cache']['hits'] ?? 0;
}
public function getMiss()
{
- return $this->data['cache']['miss'];
+ return $this->data['cache']['miss'] ?? 0;
}
public function reset()
diff --git a/src/TingBundle/DataCollector/TingDriverDataCollector.php b/src/TingBundle/DataCollector/TingDriverDataCollector.php
index 268295c..35cc52c 100644
--- a/src/TingBundle/DataCollector/TingDriverDataCollector.php
+++ b/src/TingBundle/DataCollector/TingDriverDataCollector.php
@@ -29,8 +29,9 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface;
+use Symfony\Contracts\Service\ResetInterface;
-class TingDriverDataCollector extends DataCollector implements LateDataCollectorInterface
+class TingDriverDataCollector extends DataCollector implements LateDataCollectorInterface, ResetInterface
{
/**
* @var DriverLoggerInterface|null
@@ -116,32 +117,32 @@ public function setDriverLogger(DriverLoggerInterface $driverLogger = null)
public function getQueryCount()
{
- return $this->data['driver']['queryCount'];
+ return $this->data['driver']['queryCount'] ?? 0;
}
public function getQueries()
{
- return $this->data['driver']['queries'];
+ return $this->data['driver']['queries'] ?? [];
}
public function getExecs()
{
- return $this->data['driver']['execs'];
+ return $this->data['driver']['execs'] ?? [];
}
public function getTime()
{
- return $this->data['driver']['time'];
+ return $this->data['driver']['time'] ?? 0;
}
public function getConnections()
{
- return $this->data['driver']['connections'];
+ return $this->data['driver']['connections'] ?? [];
}
public function getConnectionsHashToName()
{
- return $this->data['driver']['connectionsHashToName'];
+ return $this->data['driver']['connectionsHashToName'] ?? [];
}
public function reset()
diff --git a/src/TingBundle/Logger/CacheLogger.php b/src/TingBundle/Logger/CacheLogger.php
index e5b48fe..3443e3d 100644
--- a/src/TingBundle/Logger/CacheLogger.php
+++ b/src/TingBundle/Logger/CacheLogger.php
@@ -27,8 +27,9 @@
use CCMBenchmark\Ting\Logger\CacheLoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Stopwatch\Stopwatch;
+use Symfony\Contracts\Service\ResetInterface;
-class CacheLogger implements CacheLoggerInterface
+class CacheLogger implements CacheLoggerInterface, ResetInterface
{
protected $operationIndex = 0;
protected $operations = [];
@@ -126,4 +127,13 @@ public function getMiss()
{
return $this->miss;
}
+
+ public function reset(): void
+ {
+ $this->operationIndex = 0;
+ $this->operations = [];
+ $this->hits = 0;
+ $this->miss = 0;
+ $this->totalTime = 0;
+ }
}
diff --git a/src/TingBundle/Logger/DriverLogger.php b/src/TingBundle/Logger/DriverLogger.php
index 0e91424..3e98c8b 100644
--- a/src/TingBundle/Logger/DriverLogger.php
+++ b/src/TingBundle/Logger/DriverLogger.php
@@ -27,8 +27,9 @@
use CCMBenchmark\Ting\Logger\DriverLoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Stopwatch\Stopwatch;
+use Symfony\Contracts\Service\ResetInterface;
-class DriverLogger implements DriverLoggerInterface
+class DriverLogger implements DriverLoggerInterface, ResetInterface
{
/**
* @var null|LoggerInterface
@@ -253,4 +254,15 @@ public function getExecs()
{
return $this->execs;
}
+
+ public function reset(): void
+ {
+ $this->queries = [];
+ $this->execs = [];
+ $this->totalTime = 0;
+ $this->connections = [];
+ $this->connectionsHashToName = [];
+ $this->queryIndex = 0;
+ $this->execIndex = 0;
+ }
}
diff --git a/src/TingBundle/Resources/config/services.xml b/src/TingBundle/Resources/config/services.xml
index f3f0beb..5cb9aba 100644
--- a/src/TingBundle/Resources/config/services.xml
+++ b/src/TingBundle/Resources/config/services.xml
@@ -33,6 +33,7 @@
+
@@ -42,12 +43,14 @@
%ting.database_options%
+
+
@@ -79,10 +82,12 @@
+
+