for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Lamoda\Metric\Collector;
/**
* @internal
*/
final class CollectorRegistry
{
/** @var MetricCollectorInterface[] */
private $collectors = [];
* Add collector to registry.
*
* @param string $name
* @param MetricCollectorInterface $collector
public function register(string $name, MetricCollectorInterface $collector): void
$this->collectors[$name] = $collector;
}
* Fetch collector from registry.
* @return MetricCollectorInterface
* @throws \OutOfBoundsException
public function getCollector(string $name): MetricCollectorInterface
if (!array_key_exists($name, $this->collectors)) {
throw new \OutOfBoundsException('Unknown collector in registry: ' . $name);
return $this->collectors[$name];