Skip to content

Commit

Permalink
Merge pull request #49 from thePanz/patch-1
Browse files Browse the repository at this point in the history
Fix getName() returning null
  • Loading branch information
Oliboy50 authored Dec 14, 2017
2 parents a25f2ca + fa7d324 commit 4aef8c2
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/AmqpBundle/Amqp/DataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,14 @@
*/
class DataCollector extends SymfonyDataCollector
{
/**
* @var array
*/
protected $commands;

/**
* @var string
*/
protected $name;

/**
* @param string $name
*
* Construct the data collector
*/
public function __construct($name)
public function __construct(string $name)
{
$this->name = $name;
$this->data['name'] = $name;
$this->reset();
}

Expand Down Expand Up @@ -74,7 +64,7 @@ public function getCommands(): array
*/
public function getName(): string
{
return $this->name;
return $this->data['name'];
}

/**
Expand Down Expand Up @@ -102,6 +92,10 @@ public function getAvgExecutionTime(): float
*/
public function reset()
{
$this->data = ['commands' => []];
// Reset the current data, while keeping the 'name' intact.
$this->data = [
'name' => $this->data['name'],
'commands' => [],
];
}
}

0 comments on commit 4aef8c2

Please sign in to comment.