. */ namespace vierbergenlars\AuthserverStatsBundle\Event; use Symfony\Component\EventDispatcher\Event; class StatsEvent extends Event { private $modules; private $stats = []; public function __construct($modules) { $this->modules = $modules; } public function isEnabled($module) { if (!$this->modules) return true; return in_array($module, $this->modules); } public function addStatistics(array $statistics) { foreach ($statistics as $statName => $value) { $this->addStatistic($statName, $value); } return $this; } public function addStatistic($name, $value) { if (isset($this->stats[$name])) throw new \OutOfBoundsException(sprintf('Statistic "%s" already exists and cannot be overwritten.', $name)); $this->stats[$name] = $value; return $this; } public function getStatistics() { return $this->stats; } }